[−][src]Struct reinda::Assets
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
Auto Trait Implementations
impl RefUnwindSafe for Assets
[src]
impl Send for Assets
[src]
impl Sync for Assets
[src]
impl Unpin for Assets
[src]
impl UnwindSafe for Assets
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,