pub struct LoadContext<'a> { /* private fields */ }Expand description
Everything a loader is given for one load.
bytes is Some when an asset source (a registered .lpak bundle, say)
already produced the file contents; in that case path is the requested
path and may be a lumen://app/... URI rather than a filesystem location.
bytes is None when the path is expected to be read from disk.
Implementations§
Source§impl<'a> LoadContext<'a>
impl<'a> LoadContext<'a>
Sourcepub fn new(path: &'a Path, bytes: Option<&'a [u8]>) -> Self
pub fn new(path: &'a Path, bytes: Option<&'a [u8]>) -> Self
Builds a context for path, optionally carrying bytes an asset source
already resolved.
Sourcepub fn path(&self) -> &'a Path
pub fn path(&self) -> &'a Path
The requested path. Use it for error messages and for decoders that take a path directly.
Sourcepub fn bytes(&self) -> Option<&'a [u8]>
pub fn bytes(&self) -> Option<&'a [u8]>
Bytes an asset source already resolved, or None when the loader is
expected to read Self::path itself.
Sourcepub fn read_bytes(&self) -> Result<Cow<'a, [u8]>, LoadErrorKind>
pub fn read_bytes(&self) -> Result<Cow<'a, [u8]>, LoadErrorKind>
The asset’s bytes: the pre-resolved ones when a source supplied them, otherwise the file read from disk.
Auto Trait Implementations§
impl<'a> Freeze for LoadContext<'a>
impl<'a> RefUnwindSafe for LoadContext<'a>
impl<'a> Send for LoadContext<'a>
impl<'a> Sync for LoadContext<'a>
impl<'a> Unpin for LoadContext<'a>
impl<'a> UnsafeUnpin for LoadContext<'a>
impl<'a> UnwindSafe for LoadContext<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.