[−][src]Trait rust_embed::RustEmbed
A directory of binary assets.
They should be embedded into the executable for release builds, but can be read from the filesystem for debug builds.
This trait is meant to be derived like so:
use rust_embed::RustEmbed; #[derive(RustEmbed)] #[folder = "examples/public/"] struct Asset; fn main() {}
Required methods
pub fn get(file_path: &str) -> Option<Cow<'static, [u8]>>
[src]
Given a relative path from the assets folder, returns the bytes if found.
If the feature debug-embed
is enabled or the binary is compiled in
release mode, the bytes have been embeded in the binary and a
Cow::Borrowed(&'static [u8])
is returned.
Otherwise, the bytes are read from the file system on each call and a
Cow::Owned(Vec<u8>)
is returned.
pub fn iter() -> Filenamesⓘ
[src]
Iterates the files in this assets folder.
If the feature debug-embed
is enabled or the binary is compiled in
release mode, a static array to the list of relative paths to the files
is used.
Otherwise, the files are listed from the file system on each call.