[][src]Struct reinda::Assets

pub struct Assets { /* fields omitted */ }

A set of assets.

This is one of the two main entry points of this library. You create an instance of this type via Assets::new and then retrieve asset data via Assets::get. The macro assets! is the other main entry point of this library. It generates a Setup value at compile time which you have to pass to Assets::new.

Implementations

impl Assets[src]

pub async fn new(setup: Setup, config: Config) -> Result<Self, Error>[src]

Creates a new instance of this type and, in prod mode, prepares all assets.

pub async fn get(&self, public_path: &str) -> Result<Option<Bytes>, GetError>[src]

Returns the file contents of the asset referred to by public_path.

The given path is the "public" path, as it is a part of the actual request URI. This doesn't mean this parameter has to be the full path component from the request URI; you likely want to serve your assets in a subdirectory, like /assets/ which you would have to remove from the URI-path before calling this method. However, for assets with hashed filenames, this method expects the hashed path and not the one you specified in assets!.

If no asset with the specified path exists, Ok(None) is returned. An error is returned in debug mode for a variety of reasons. In release mode, this method always returns Ok(_). See GetError.

pub fn asset_ids(&self) -> impl Iterator<Item = AssetId>[src]

Returns an iterator over the IDs of all assets.

pub fn asset_info(&self, id: AssetId) -> Option<Info<'_>>[src]

Returns meta information about a specific asset, or None if no asset with the given ID exists.

Trait Implementations

impl Debug for Assets[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.