Skip to main content

LumenBundle

Struct LumenBundle 

Source
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

Source

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.

Source

pub fn from_bytes(blob: impl Into<Vec<u8>>) -> Result<Self, BundleError>

Build a bundle from raw bytes (e.g. include_bytes!("app.lpak")).

Source

pub fn len(&self) -> usize

Number of files in the archive.

Source

pub fn is_empty(&self) -> bool

Is the archive empty?

Source

pub fn entries(&self) -> impl Iterator<Item = &str>

List logical entry names in unspecified order. Useful for font-discovery passes that filter on extension.

Source

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.

Source

pub fn contains(&self, name: &str) -> bool

Whether name exists in the archive.

Source

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).

Source

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

Source§

fn clone(&self) -> LumenBundle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LumenBundle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoResult<T> for T

§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ConditionalSend for T
where T: Send,