~repos /rust-embed

#rust#proc-macro#http

git clone https://pyrossh.dev/repos/rust-embed.git
Discussions: https://groups.google.com/g/rust-embed-devs

rust macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.


Files changed (4) hide show
  1. Cargo.toml +2 -2
  2. changelog.md +12 -0
  3. impl/Cargo.toml +1 -1
  4. readme.md +5 -5
Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "rust-embed"
3
- version = "4.1.0"
3
+ version = "4.2.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"
@@ -12,7 +12,7 @@ authors = ["pyros2097 <pyros2097@gmail.com>"]
12
12
 
13
13
  [dependencies]
14
14
  walkdir = "2.1.4"
15
- rust-embed-impl = { version = "4.1.0", path = "impl"}
15
+ rust-embed-impl = { version = "4.2.0", path = "impl"}
16
16
 
17
17
  actix-web = { version = "0.7", optional = true }
18
18
  mime_guess = { version = "2.0.0-alpha.6", optional = true }
changelog.md CHANGED
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  Thanks to [Mcat12](https://github.com/Mcat12) for the changelog.
8
8
 
9
+ ## [4.2.0] - 2018-12-02
10
+ ### Changed
11
+ - return `Cow<'static, [u8]>` to preserve static lifetime
12
+
13
+ ## [4.1.0] - 2018-10-24
14
+ ### Added
15
+ - `iter()` method to list files
16
+
17
+ ## [4.0.0] - 2018-10-11
18
+ ### Changed
19
+ - avoid vector allocation by returning `impl AsRef<[u8]>`
20
+
9
21
  ## [3.0.2] - 2018-09-05
10
22
  ### Added
11
23
  - appveyor for testing on windows
impl/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "rust-embed-impl"
3
- version = "4.1.0"
3
+ version = "4.2.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
  ```toml
15
15
  [dependencies]
16
- rust-embed="4.1.0"
16
+ rust-embed="4.2.0"
17
17
  ```
18
18
 
19
19
  ## Documentation
@@ -36,11 +36,11 @@ The macro will generate the following code:
36
36
 
37
37
  ```rust
38
38
  impl Asset {
39
- pub fn get(file_path: &str) -> Option<impl AsRef<[u8]>> {
39
+ pub fn get(file_path: &str) -> Option<Cow<'static, [u8]>> {
40
40
  ...
41
41
  }
42
42
 
43
- pub fn iter() -> impl Iterator<Item = impl AsRef<str>> {
43
+ pub fn iter() -> impl Iterator<Item = Cow<'static, str>> {
44
44
  ...
45
45
  }
46
46
  }
@@ -50,9 +50,9 @@ impl Asset {
50
50
 
51
51
  Given a relative path from the assets folder returns the bytes if found.
52
52
 
53
- If the feature `debug-embed` is enabled or the binary compiled in release mode the bytes have been embeded in the binary and a `&'static [u8]` is returned.
53
+ If the feature `debug-embed` is enabled or the binary compiled in release mode the bytes have been embeded in the binary and a `Cow::Borrowed(&'static [u8])` is returned.
54
54
 
55
- Otherwise the bytes are read from the file system on each call and a `Vec<u8>` is returned.
55
+ Otherwise the bytes are read from the file system on each call and a `Cow::Owned(Vec<u8>)` is returned.
56
56
 
57
57
 
58
58
  ### `iter()`