Skip to main content

EmbeddedFile

Struct EmbeddedFile 

Source
pub struct EmbeddedFile {
    pub url: &'static str,
    pub hashed_url: Option<&'static str>,
    pub logical_path: &'static str,
    pub bytes: &'static [u8],
    pub content_type: &'static str,
    pub etag: &'static str,
    pub hash: &'static str,
}
Expand description

A single embedded asset: its content plus the metadata needed to serve it.

Values of this type are generated at build time and stored in a static slice; you do not construct them by hand.

Every file records its stable, non-hashed url. Files that are content-hashed (the default) are served at their cache-busted hashed_url; files in an immutable_dir are not re-hashed, have hashed_url == None, and are served at their plain url.

Fields§

§url: &'static str

The stable, non-hashed URL mirroring the file’s path under the crate root with a leading slash, e.g. /assets/css/style.css. This URL is served only for assets in an immutable_dir; ordinary assets are served only at their hashed_url.

§hashed_url: Option<&'static str>

The full, content-hashed, cache-busted URL, e.g. /assets/css/style.9f3a1c2b.css, served immutable. None for assets in an immutable_dir (already immutable, so not re-hashed). When present, this is what the generated asset! macro and Assets::url prefer.

§logical_path: &'static str

The original path of the file relative to the crate root, e.g. assets/css/style.css — the key you pass to asset! and Assets::get_logical.

§bytes: &'static [u8]

The raw file contents (via include_bytes!).

§content_type: &'static str

The guessed MIME type, e.g. text/css.

§etag: &'static str

A strong, quoted ETag derived from the content hash, e.g. "\"9f3a1c2b…\"".

§hash: &'static str

The hex content hash used for cache busting and the ETag.

Trait Implementations§

Source§

impl Clone for EmbeddedFile

Source§

fn clone(&self) -> EmbeddedFile

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 Copy for EmbeddedFile

Source§

impl Debug for EmbeddedFile

Source§

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

Formats the value using the given formatter. 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, 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.