20 lines
448 B
Markdown
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 dir_embed::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}");
|
|
}
|
|
```
|
|
|