~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.
eb42c093
—
Paolo Barbolini 5 years ago
rustc: upgrade to the 2018 edition
- Cargo.toml +1 -0
- examples/actix.rs +0 -4
- examples/basic.rs +0 -2
- examples/rocket.rs +0 -1
- examples/warp.rs +0 -3
- impl/Cargo.toml +1 -0
- impl/src/lib.rs +1 -6
- src/lib.rs +0 -5
- tests/interpolated_path.rs +6 -9
- tests/lib.rs +6 -9
- utils/Cargo.toml +1 -0
- utils/src/lib.rs +0 -3
Cargo.toml
CHANGED
|
@@ -9,6 +9,7 @@ license = "MIT"
|
|
|
9
9
|
keywords = ["http", "rocket", "static", "web", "server"]
|
|
10
10
|
categories = ["web-programming::http-server"]
|
|
11
11
|
authors = ["pyros2097 <pyros2097@gmail.com>"]
|
|
12
|
+
edition = "2018"
|
|
12
13
|
|
|
13
14
|
[dependencies]
|
|
14
15
|
walkdir = "2.2.7"
|
examples/actix.rs
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
extern crate actix_web;
|
|
2
|
-
extern crate mime_guess;
|
|
3
|
-
extern crate rust_embed;
|
|
4
|
-
|
|
5
1
|
use actix_web::body::Body;
|
|
6
2
|
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};
|
|
7
3
|
use mime_guess::from_path;
|
examples/basic.rs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
extern crate rust_embed;
|
|
2
|
-
|
|
3
1
|
use rust_embed::RustEmbed;
|
|
4
2
|
|
|
5
3
|
#[derive(RustEmbed)]
|
examples/rocket.rs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#![feature(decl_macro, proc_macro_hygiene)]
|
|
2
2
|
#[macro_use]
|
|
3
3
|
extern crate rocket;
|
|
4
|
-
extern crate rust_embed;
|
|
5
4
|
|
|
6
5
|
use rocket::http::{ContentType, Status};
|
|
7
6
|
use rocket::response;
|
examples/warp.rs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
extern crate rust_embed;
|
|
2
|
-
extern crate warp;
|
|
3
|
-
|
|
4
1
|
use rust_embed::RustEmbed;
|
|
5
2
|
use warp::{filters::path::Tail, http::Response, Filter, Rejection, Reply};
|
|
6
3
|
|
impl/Cargo.toml
CHANGED
|
@@ -9,6 +9,7 @@ license = "MIT"
|
|
|
9
9
|
keywords = ["http", "rocket", "static", "web", "server"]
|
|
10
10
|
categories = ["web-programming::http-server"]
|
|
11
11
|
authors = ["pyros2097 <pyros2097@gmail.com>"]
|
|
12
|
+
edition = "2018"
|
|
12
13
|
|
|
13
14
|
[lib]
|
|
14
15
|
proc-macro = true
|
impl/src/lib.rs
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
#![recursion_limit = "1024"]
|
|
2
|
-
extern crate proc_macro;
|
|
3
2
|
#[macro_use]
|
|
4
3
|
extern crate quote;
|
|
5
|
-
extern crate syn;
|
|
6
|
-
|
|
7
|
-
#[cfg(feature = "interpolate-folder-path")]
|
|
8
|
-
extern crate shellexpand;
|
|
9
|
-
extern crate
|
|
4
|
+
extern crate proc_macro;
|
|
10
5
|
|
|
11
6
|
use proc_macro::TokenStream;
|
|
12
7
|
use std::path::Path;
|
src/lib.rs
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
#[cfg(all(debug_assertions, not(feature = "debug-embed")))]
|
|
2
|
-
extern crate walkdir;
|
|
3
|
-
|
|
4
|
-
#[cfg(feature = "compression")]
|
|
5
|
-
extern crate include_flate;
|
|
6
1
|
#[cfg(feature = "compression")]
|
|
7
2
|
#[cfg_attr(feature = "compression", doc(hidden))]
|
|
8
3
|
pub use include_flate::flate;
|
tests/interpolated_path.rs
CHANGED
|
@@ -7,17 +7,14 @@ struct Asset;
|
|
|
7
7
|
|
|
8
8
|
#[test]
|
|
9
9
|
fn get_works() {
|
|
10
|
-
|
|
10
|
+
if Asset::get("index.html").is_none() {
|
|
11
|
-
|
|
11
|
+
panic!("index.html should exist");
|
|
12
|
-
_ => assert!(true),
|
|
13
12
|
}
|
|
14
|
-
|
|
13
|
+
if Asset::get("gg.html").is_some() {
|
|
15
|
-
|
|
14
|
+
panic!("gg.html should not exist");
|
|
16
|
-
_ => assert!(true),
|
|
17
15
|
}
|
|
18
|
-
|
|
16
|
+
if Asset::get("images/llama.png").is_none() {
|
|
19
|
-
|
|
17
|
+
panic!("llama.png should exist");
|
|
20
|
-
_ => assert!(true),
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
20
|
|
tests/lib.rs
CHANGED
|
@@ -7,17 +7,14 @@ struct Asset;
|
|
|
7
7
|
|
|
8
8
|
#[test]
|
|
9
9
|
fn get_works() {
|
|
10
|
-
|
|
10
|
+
if Asset::get("index.html").is_none() {
|
|
11
|
-
|
|
11
|
+
panic!("index.html should exist");
|
|
12
|
-
_ => assert!(true),
|
|
13
12
|
}
|
|
14
|
-
|
|
13
|
+
if Asset::get("gg.html").is_some() {
|
|
15
|
-
|
|
14
|
+
panic!("gg.html should not exist");
|
|
16
|
-
_ => assert!(true),
|
|
17
15
|
}
|
|
18
|
-
|
|
16
|
+
if Asset::get("images/llama.png").is_none() {
|
|
19
|
-
|
|
17
|
+
panic!("llama.png should exist");
|
|
20
|
-
_ => assert!(true),
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
20
|
|
utils/Cargo.toml
CHANGED
|
@@ -9,6 +9,7 @@ license = "MIT"
|
|
|
9
9
|
keywords = ["http", "rocket", "static", "web", "server"]
|
|
10
10
|
categories = ["web-programming::http-server"]
|
|
11
11
|
authors = ["pyros2097 <pyros2097@gmail.com>"]
|
|
12
|
+
edition = "2018"
|
|
12
13
|
|
|
13
14
|
[dependencies]
|
|
14
15
|
walkdir = "2.2.7"
|
utils/src/lib.rs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
#[cfg(all(debug_assertions, not(feature = "debug-embed")))]
|
|
2
|
-
extern crate walkdir;
|
|
3
|
-
|
|
4
1
|
#[cfg_attr(all(debug_assertions, not(feature = "debug-embed")), allow(unused))]
|
|
5
2
|
pub struct FileEntry {
|
|
6
3
|
pub rel_path: String,
|