pub struct LumenBundle { /* private fields */ }Expand description
In-memory .lpak archive. Holds the raw blob plus an index from
virtual path -> byte range so reads are O(1).
Implementations§
Source§impl LumenBundle
impl LumenBundle
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, BundleError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, BundleError>
Open a .lpak from disk, parse the header, and build the
in-memory index. The full blob is read into memory; typical
bundles are < 50 MiB so this is fine for the v1 use cases.
Sourcepub fn from_bytes(blob: impl Into<Vec<u8>>) -> Result<Self, BundleError>
pub fn from_bytes(blob: impl Into<Vec<u8>>) -> Result<Self, BundleError>
Build a bundle from raw bytes (e.g. include_bytes!("app.lpak")).
Sourcepub fn entries(&self) -> impl Iterator<Item = &str>
pub fn entries(&self) -> impl Iterator<Item = &str>
List logical entry names in unspecified order. Useful for font-discovery passes that filter on extension.
Sourcepub fn read(&self, name: &str) -> Option<Vec<u8>>
pub fn read(&self, name: &str) -> Option<Vec<u8>>
Look up the raw bytes for name. Returns None when the
entry isn’t in the archive. The returned Vec<u8> is a fresh
owned copy - bundles are immutable so the slice could in
theory be loaned, but mirroring Vec<u8> keeps the call site
uniform with disk-loaded paths.
Sourcepub fn slice(&self, name: &str) -> Option<&[u8]>
pub fn slice(&self, name: &str) -> Option<&[u8]>
Borrow the entry bytes without copying. Used by the font-db
registration path which feeds the slice straight into
cosmic_text::fontdb::Database::load_font_data (which copies
internally anyway).
Sourcepub fn pack_dir(
root: impl AsRef<Path>,
out: impl AsRef<Path>,
) -> Result<usize, BundleError>
pub fn pack_dir( root: impl AsRef<Path>, out: impl AsRef<Path>, ) -> Result<usize, BundleError>
Package a directory tree into a .lpak written to out.
root is walked recursively; each visited file becomes an
entry keyed by its path RELATIVE to root, with forward
slashes. Symlinks are followed.
A src/ directory at root is left out: an app’s code is compiled,
never looked up by name at run time, so a bundle holds assets only.
Returns the number of entries written.
Trait Implementations§
Source§impl Clone for LumenBundle
impl Clone for LumenBundle
Source§fn clone(&self) -> LumenBundle
fn clone(&self) -> LumenBundle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more