pub struct AssetBundle { /* private fields */ }Expand description
Asset key → bytes (or a digest with bytes fetched lazily), for one render.
Implementations§
Source§impl AssetBundle
impl AssetBundle
pub fn new() -> Self
Sourcepub fn insert(
&mut self,
key: impl Into<String>,
bytes: impl Into<Bytes>,
) -> Option<Bytes>
pub fn insert( &mut self, key: impl Into<String>, bytes: impl Into<Bytes>, ) -> Option<Bytes>
Declare key, returning the bytes it previously held (a previously
digest-only entry reports None — there were no bytes in hand).
Sourcepub fn with(self, key: impl Into<String>, bytes: impl Into<Bytes>) -> Self
pub fn with(self, key: impl Into<String>, bytes: impl Into<Bytes>) -> Self
AssetBundle::insert for chaining at a call site.
Sourcepub fn insert_digest<F, Fut, E>(
&mut self,
key: impl Into<String>,
digest: Digest,
fetch: F,
) -> Option<Bytes>
pub fn insert_digest<F, Fut, E>( &mut self, key: impl Into<String>, digest: Digest, fetch: F, ) -> Option<Bytes>
Declare key by digest only: manifest()/bind() use digest
without ever calling fetch, which only runs if the server’s 409
actually names this digest — the steady-state case for a caller whose
storage is already content-addressed never touches the bytes at all.
fetch may be called again on a retry of the same bundle, so it
should be idempotent; a fetch that fails, or whose bytes hash to
something other than digest, surfaces as
Error::BlobFetchFailed or
Error::DigestMismatch when the
upload it was needed for runs — never a silent skip.
Sourcepub fn with_digest<F, Fut, E>(
self,
key: impl Into<String>,
digest: Digest,
fetch: F,
) -> Self
pub fn with_digest<F, Fut, E>( self, key: impl Into<String>, digest: Digest, fetch: F, ) -> Self
AssetBundle::insert_digest for chaining at a call site.
Sourcepub fn get(&self, key: &str) -> Option<&Bytes>
pub fn get(&self, key: &str) -> Option<&Bytes>
The bytes key holds, if it was declared eagerly. None both for an
absent key and for one declared with AssetBundle::with_digest —
use Client::check / render to reach a
digest-only entry’s bytes, since fetching them is async.
pub fn keys(&self) -> impl Iterator<Item = &str>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn manifest(&self) -> AssetManifest
pub fn manifest(&self) -> AssetManifest
The manifest naming every asset in the bundle by digest. Never touches a digest-only entry’s bytes.