From 1a81ce8376a9f6dba40021f13b77b98375429b11 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Mon, 28 Jul 2025 20:50:54 +0200 Subject: [PATCH] updated README with new modes --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 8443dcc..6f81462 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,17 @@ Simple way to use [`include_bytes!`](https://doc.rust-lang.org/std/macro.include_bytes.html) for directories. # Example + +You can embed files two ways. + +## Bytes mode + ```rust use dir_embed::Embed; #[derive(Embed)] #[dir = "../web/static"] // Path is relativ to the current file +#[mode = "bytes"] // Is the default. Can be omitted. pub struct Assets; fn main(){ @@ -17,3 +23,19 @@ fn main(){ } ``` +## Str mode + +```rust +use dir_embed::Embed; + +#[derive(Embed)] +#[dir = "../web/static"] // Path is relativ to the current file +#[mode = "str"] +pub struct Assets; + +fn main(){ + let file: &str = Assets::get("css/style.css").expect("Can't find file"); + + println!("{file}"); +} +```