embed-dir/README.md
2025-07-28 19:35:48 +02:00

20 lines
448 B
Markdown

Simple way to use [`include_bytes!`](https://doc.rust-lang.org/std/macro.include_bytes.html) for directories.
# Example
```rust
use embed_dir::Embed;
#[derive(Embed)]
#[dir = "../web/static"] // Path is relativ to the current file
pub struct Assets;
fn main(){
let file: &[u8] = Assets::get("css/style.css").expect("Can't find file");
let string = str::from_utf8(file).expect("Failed to parse file");
println!("{string}");
}
```