~repos /rust-embed
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.
3824aa16
—
pyros2097 7 years ago
Merge branches 'master' and 'master' of github.com:pyros2097/rust-embed
readme.md
CHANGED
|
@@ -23,7 +23,7 @@ rust-embed="0.3.0"
|
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Documentation
|
|
26
|
-
|
|
26
|
+
The `embed!` macro takes a folder path and returns a function which allows you to get the file by passing the file path within the folder. So now you can statically compile all your assets i.e. your /static/ or /public/ folders into the rust executable and serve them during release and in development it will load the file from the file
|
|
27
27
|
system so that it doesn't take to much time to compile;]
|
|
28
28
|
|
|
29
29
|
```rust
|
|
@@ -35,6 +35,8 @@ asset(path: String) -> Option<Vec<u8>>
|
|
|
35
35
|
#[macro_use]
|
|
36
36
|
extern crate rust_embed;
|
|
37
37
|
|
|
38
|
+
use rust_embed::*;
|
|
39
|
+
|
|
38
40
|
fn main() {
|
|
39
41
|
let asset = embed!("examples/public/".to_owned());
|
|
40
42
|
let index_html = asset("index.html".to_owned()).unwrap();
|