~repos /rust-embed

#rust#proc-macro#http

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.


3c3c6bed pyros2097

7 years ago
Improve documentation a bit
Files changed (1) hide show
  1. readme.md +5 -1
readme.md CHANGED
@@ -17,12 +17,16 @@ rust-embed="3.0.0"
17
17
  ```
18
18
 
19
19
  ## Documentation
20
- Declare a struct name it Asset or something and add an attribute `folder` to it which has the path to your static folder.
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