pub struct AssetArchive { /* private fields */ }Expand description
Client assets packed by writeAssetArchive in fetchlet/build.
The archive is checked once in AssetArchive::new; lookups and reads
then index into the same bytes. Embed it with
AssetArchive::new(Bytes::from_static(include_bytes!(...))) or read a
sidecar file with AssetArchive::open.
Implementations§
Source§impl AssetArchive
impl AssetArchive
Sourcepub fn new(bytes: impl Into<Bytes>) -> Result<Self, AssetArchiveError>
pub fn new(bytes: impl Into<Bytes>) -> Result<Self, AssetArchiveError>
Check bytes and index its entries.
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, AssetArchiveError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, AssetArchiveError>
Read and check an archive file, such as a sidecar next to the binary.
Sourcepub fn get(&self, path: &str) -> Option<Asset<'_>>
pub fn get(&self, path: &str) -> Option<Asset<'_>>
The asset at a decoded URL path, such as /assets/app.js.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for AssetArchive
impl Clone for AssetArchive
Auto Trait Implementations§
impl !Freeze for AssetArchive
impl Forget for AssetArchive
impl Move for AssetArchive
impl RefUnwindSafe for AssetArchive
impl Send for AssetArchive
impl Sync for AssetArchive
impl Unpin for AssetArchive
impl UnsafeUnpin for AssetArchive
impl UnwindSafe for AssetArchive
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