~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.
dc0fae9f
—
Bernardo 7 years ago
update readme and bump version
- Cargo.toml +1 -1
- readme.md +4 -4
Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "rust-embed"
|
|
3
|
-
version = "
|
|
3
|
+
version = "4.0.0"
|
|
4
4
|
description = "Rust Custom Derive Macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev"
|
|
5
5
|
readme = "readme.md"
|
|
6
6
|
documentation = "https://docs.rs/rust-embed"
|
readme.md
CHANGED
|
@@ -13,7 +13,7 @@ You can use this to embed your css, js and images into a single executable which
|
|
|
13
13
|
|
|
14
14
|
```
|
|
15
15
|
[dependencies]
|
|
16
|
-
rust-embed="
|
|
16
|
+
rust-embed="4.0.0"
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Documentation
|
|
@@ -23,9 +23,9 @@ You need to add the custom derive macro RustEmbed to your struct with an attribu
|
|
|
23
23
|
#[folder = "examples/public/"]
|
|
24
24
|
struct Asset;
|
|
25
25
|
```
|
|
26
|
-
This macro adds 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
|
|
26
|
+
This macro adds 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 `Option` with the bytes.
|
|
27
27
|
```rust
|
|
28
|
-
pub fn get(file_path: &str) -> Option<
|
|
28
|
+
pub fn get(file_path: &str) -> Option<impl AsRef<[u8]>>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
## Usage
|
|
@@ -39,7 +39,7 @@ struct Asset;
|
|
|
39
39
|
|
|
40
40
|
fn main() {
|
|
41
41
|
let index_html = Asset::get("index.html").unwrap();
|
|
42
|
-
println!("{:?}", std::str::from_utf8(
|
|
42
|
+
println!("{:?}", std::str::from_utf8(index_html.as_ref()));
|
|
43
43
|
}
|
|
44
44
|
```
|
|
45
45
|
|