pub trait RustEmbed {
// Required methods
fn get(file_path: &str) -> Option<EmbeddedFile>;
fn iter() -> Filenames ⓘ;
}
Expand description
A directory of binary assets.
The files in the specified folder will be embedded into the executable in release builds. Debug builds will read the data from the file system at runtime.
This trait is meant to be derived like so:
use rust_embed::RustEmbed;
#[derive(RustEmbed)]
#[folder = "examples/public/"]
struct Asset;
fn main() {}
Required Methods§
sourcefn get(file_path: &str) -> Option<EmbeddedFile>
fn get(file_path: &str) -> Option<EmbeddedFile>
Get an embedded file and its metadata.
If the feature debug-embed
is enabled or the binary was compiled in
release mode, the file information is embedded in the binary and the file
data is returned as a Cow::Borrowed(&'static [u8])
.
Otherwise, the information is read from the file system on each call and
the file data is returned as a Cow::Owned(Vec<u8>)
.
Object Safety§
This trait is not object safe.