~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.
248743a9
—
pyros2097 7 years ago
Merge branch 'master' of github.com:pyros2097/rust-embed
- .travis.yml +22 -0
- readme.md +13 -7
.travis.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
language: rust
|
|
2
|
+
sudo: false
|
|
3
|
+
dist: trusty
|
|
4
|
+
|
|
5
|
+
cache:
|
|
6
|
+
cargo: true
|
|
7
|
+
|
|
8
|
+
matrix:
|
|
9
|
+
include:
|
|
10
|
+
- rust: 1.21.0
|
|
11
|
+
- rust: stable
|
|
12
|
+
- rust: beta
|
|
13
|
+
- rust: nightly
|
|
14
|
+
allow_failures:
|
|
15
|
+
- rust: nightly
|
|
16
|
+
- rust: beta
|
|
17
|
+
|
|
18
|
+
script:
|
|
19
|
+
- |
|
|
20
|
+
cargo clean
|
|
21
|
+
cargo test --lib
|
|
22
|
+
cargo test --lib --release
|
readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## Rust Embed
|
|
1
|
+
## Rust Embed [](https://travis-ci.org/pyros2097/rust-embed) [](https://crates.io/crates/rust-embed)
|
|
2
2
|
Rust Marco which loads files into the rust binary at compile time during release and loads the file from the fs during dev.
|
|
3
3
|
|
|
4
4
|
You can use this to embed your css, js and images into a single executable.
|
|
@@ -28,11 +28,17 @@ system so that it doesn't take to much time to compile;]
|
|
|
28
28
|
|
|
29
29
|
```rust
|
|
30
30
|
asset(path: String) -> Option<Vec<u8>>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
```rust
|
|
35
|
+
#[macro_use]
|
|
36
|
+
extern crate rust_embed;
|
|
31
37
|
|
|
38
|
+
fn main() {
|
|
32
|
-
let asset = embed!("examples/public".to_owned());
|
|
39
|
+
let asset = embed!("examples/public".to_owned());
|
|
33
|
-
|
|
40
|
+
let index_html = asset("/index.html".to_owned()).unwrap();
|
|
34
|
-
|
|
41
|
+
println!("{}", index_html);
|
|
35
|
-
_ => assert!(true),
|
|
36
42
|
}
|
|
37
43
|
```
|
|
38
44
|
|
|
@@ -41,9 +47,9 @@ To run the examples,
|
|
|
41
47
|
`cargo run --example hyper`
|
|
42
48
|
|
|
43
49
|
## Testing
|
|
44
|
-
debug: `cargo test --lib
|
|
50
|
+
debug: `cargo test --lib
|
|
45
51
|
|
|
46
|
-
release: `cargo test --lib --release
|
|
52
|
+
release: `cargo test --lib --release
|
|
47
53
|
|
|
48
54
|
Go Rusketeers!
|
|
49
55
|
The power is yours!
|