Skip to main content

AssetBundle

Struct AssetBundle 

Source
pub struct AssetBundle { /* private fields */ }
Expand description

Asset key → bytes (or a digest with bytes fetched lazily), for one render.

Implementations§

Source§

impl AssetBundle

Source

pub fn new() -> Self

Source

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

Source

pub fn with(self, key: impl Into<String>, bytes: impl Into<Bytes>) -> Self

AssetBundle::insert for chaining at a call site.

Source

pub fn insert_digest<F, Fut, E>( &mut self, key: impl Into<String>, digest: Digest, fetch: F, ) -> Option<Bytes>
where F: Fn() -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Bytes, E>> + Send + 'static, E: Error + Send + Sync + 'static,

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.

Source

pub fn with_digest<F, Fut, E>( self, key: impl Into<String>, digest: Digest, fetch: F, ) -> Self
where F: Fn() -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Bytes, E>> + Send + 'static, E: Error + Send + Sync + 'static,

AssetBundle::insert_digest for chaining at a call site.

Source

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.

Source

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

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn manifest(&self) -> AssetManifest

The manifest naming every asset in the bundle by digest. Never touches a digest-only entry’s bytes.

Trait Implementations§

Source§

impl Clone for AssetBundle

Source§

fn clone(&self) -> Self

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 AssetBundle

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for AssetBundle

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<K: Into<String>, V: Into<Bytes>> FromIterator<(K, V)> for AssetBundle

Source§

fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self

Creates a value from an iterator. 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.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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