~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.
7cc08bff
—
pyros2097 9 years ago
Update README.md
README.md
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
## Rust Embed
|
|
2
2
|
Generates rust code to embed resource files into your rust executable
|
|
3
3
|
|
|
4
|
-
# TODO
|
|
5
|
-
rewrite this to use compiler plugins and macro so that we can use that instead
|
|
6
|
-
|
|
7
4
|
```bash
|
|
8
5
|
./rust-embed
|
|
9
6
|
|
|
10
7
|
rust-embed v0.1.0
|
|
11
|
-
Generates rust code to embed resource files into your library or executable
|
|
8
|
+
Generates rust code to embed resource files/folders at compile time into your library or executable
|
|
12
9
|
|
|
13
10
|
Usage:
|
|
14
11
|
rust-embed input_folder output_file
|
|
@@ -29,31 +26,16 @@ This is similar to [pony-embed](https://github.com/pyros2097/pony-embed).
|
|
|
29
26
|
|
|
30
27
|
## Installation
|
|
31
28
|
|
|
32
|
-
> **Note:** this method currently requires you to be running cargo 0.6.0 or
|
|
33
|
-
> newer.
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
cargo install --git https://github.com/pyros2097/rust-embed
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
or if you're using [`multirust`](https://github.com/brson/multirust)
|
|
40
|
-
|
|
41
29
|
```
|
|
42
|
-
|
|
30
|
+
cargo install rust-embed
|
|
43
31
|
```
|
|
44
32
|
|
|
45
|
-
|
|
46
33
|
## Documentation
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
You can directly access your files as constants from the assets module or
|
|
50
|
-
you can use this function to serve all files stored in your assets folder which might be useful for webservers.
|
|
34
|
+
It exposes a function to serve all files stored in your assets folder which is useful for webservers. So now you can statically compile all your assets i.e. your /static/ or /public/ folders into the rust executable and serve them. So now you don't need to package your assets with your executable.
|
|
51
35
|
|
|
52
36
|
```rust
|
|
53
|
-
assets:index_html // direct access
|
|
54
|
-
|
|
55
|
-
assets::get(
|
|
37
|
+
assets::get(path: str)
|
|
56
|
-
// This will return the data for the specified
|
|
38
|
+
// This will return the data for the file specified by the file path or will throw an error if it cannot be found.
|
|
57
39
|
```
|
|
58
40
|
|
|
59
41
|
## Examples
|
|
@@ -88,3 +70,6 @@ fn main() {
|
|
|
88
70
|
|
|
89
71
|
Go Rusketeers!
|
|
90
72
|
The power is yours!
|
|
73
|
+
|
|
74
|
+
# TODO
|
|
75
|
+
rewrite this to use compiler plugins and macro so that we can use that instead
|