~repos /rust-embed

#rust#proc-macro#http

git clone https://pyrossh.dev/repos/rust-embed.git

rust macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.


file:

examples/basic.rs

use rust_embed::Embed;
#[derive(Embed)]
#[folder = "examples/public/"]
struct Asset;
fn main() {
let index_html = Asset::get("index.html").unwrap();
println!("{:?}", std::str::from_utf8(index_html.data.as_ref()));
}