[][src]Trait rust_embed::RustEmbed

pub trait RustEmbed {
    fn get(file_path: &str) -> Option<Cow<'static, [u8]>>;
fn iter() -> Filenames

Important traits for Filenames

impl Iterator for Filenames type Item = Cow<'static, str>;
; }

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

fn get(file_path: &str) -> Option<Cow<'static, [u8]>>

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.

fn iter() -> Filenames

Important traits for Filenames

impl Iterator for Filenames type Item = Cow<'static, str>;

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.

Loading content...

Implementors

Loading content...