rust rust_embed 方便资源嵌入到rust 应用程序中的包
rust-embed是一个自定义的derive macro,可以方便的将资源嵌入到rust 引用程序中
参考使用
use rust_embed::Embed;
#[derive(Embed)]
#[folder = "examples/public/"]
#[prefix = "prefix/"]
struct Asset;
fn main() {
let index_html = Asset::get("prefix/index.html").unwrap();
println!("{:?}", std::str::from_utf8(index_html.data.as_ref()));
for file in Asset::iter() {
println!("{}", file.as_ref());
}
}
说明
有不少应用使用了此包,比如ratch-job 等
参考资料
https://crates.io/crates/rust-embed
浙公网安备 33010602011771号