Skip to main content

Embed

Derive Macro Embed 

Source
#[derive(Embed)]
{
    // Attributes available to this derive:
    #[embed]
}
Expand description

Derive the Embed trait for unit struct, embedding assets from a folder.

§Usage

Apply #[derive(Embed)] to a unit struct and specify the folder to embed using the #[embed(folder = "...")] attribute.

Optionally, specify the crate path with #[embed(crate = path)]. This is applicable when invoking re-exported derive from a public macro in a different crate.

The name of file to serve as index for directories can be customized using #[embed(index = “…”)], the default is “index.html”.

If the astro feature is enabled, you can enable Astro support using the attributes astro. In such case, if folder is not specified, the project root used is the manifest folder. For astro projects, the index attribute cannot be used to customize the index for directories.