rust-embed v8.11.0
git clone https://git.pyrossh.dev/rust-embed
rust macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.
3c3c6be
— pyros2097
2018-09-24T11:38:27+05:30
Improve documentation a bit
readme.md
CHANGED
|
@@ -17,12 +17,16 @@ rust-embed="3.0.0"
|
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Documentation
|
|
20
|
-
|
|
20
|
+
You need to add the custom derive macro RustEmbed to your struct with an attribute `folder` which is the path to your static folder.
|
|
21
21
|
```rust
|
|
22
22
|
#[derive(RustEmbed)]
|
|
23
23
|
#[folder = "examples/public/"]
|
|
24
24
|
struct Asset;
|
|
25
25
|
```
|
|
26
|
+
This macro add a single static method `get` to your type. This method allows you to get your assets from the fs during dev and from the binary during release. It takes the file path as string and returns an an optional vector of u8.
|
|
27
|
+
```rust
|
|
28
|
+
pub fn get(file_path: &str) -> Option<Vec<u8>>
|
|
29
|
+
```
|
|
26
30
|
|
|
27
31
|
## Usage
|
|
28
32
|
```rust
|