pub struct PackLoader { /* private fields */ }Expand description
Pack-based asset loader for release mode.
Reads assets from a .pack archive file by seeking to the recorded
offset (shifted by PACK_HEADER_SIZE) and reading the specified
number of bytes.
Implementations§
Source§impl PackLoader
impl PackLoader
Sourcepub fn new(pack_file: File) -> Result<Self>
pub fn new(pack_file: File) -> Result<Self>
Validates the leading header and returns a reader bound to
pack_file.
Errors:
- file shorter than
PACK_HEADER_SIZEor unreadable, - magic doesn’t match
PACK_MAGIC(file isn’t a Khora pack), format_versionfield doesn’t matchPACK_FORMAT_VERSION(this runtime can’t read this pack — typically an older runtime reading a newer pack).
Sourcepub fn header(&self) -> &PackHeader
pub fn header(&self) -> &PackHeader
Returns a reference to the parsed header. Useful for diagnostics
and for asserting header.asset_count == vfs.asset_count() at
startup.
Sourcepub fn write_header(
out: &mut impl Write,
asset_count: u32,
flags: u32,
) -> Result<()>
pub fn write_header( out: &mut impl Write, asset_count: u32, flags: u32, ) -> Result<()>
Writes a fresh 24-byte header at the start of out. Convenience
helper for crate::asset::PackBuilder — keeps all the byte-
layout knowledge in one module.
Trait Implementations§
Source§impl AssetIo for PackLoader
impl AssetIo for PackLoader
Auto Trait Implementations§
impl Freeze for PackLoader
impl RefUnwindSafe for PackLoader
impl Send for PackLoader
impl Sync for PackLoader
impl Unpin for PackLoader
impl UnsafeUnpin for PackLoader
impl UnwindSafe for PackLoader
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more