~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.
ac96d40f
—
pyros2097 7 years ago
remove logger
- examples/basic.rs +0 -16
- examples/rocket.rs +0 -16
examples/basic.rs
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
#![feature(attr_literals)]
|
|
2
2
|
#[macro_use]
|
|
3
|
-
extern crate log;
|
|
4
|
-
#[macro_use]
|
|
5
3
|
extern crate rust_embed;
|
|
6
|
-
extern crate fern;
|
|
7
4
|
|
|
8
5
|
#[derive(RustEmbed)]
|
|
9
6
|
#[folder("examples/public/")]
|
|
10
7
|
struct Asset;
|
|
11
8
|
|
|
12
9
|
fn main() {
|
|
13
|
-
fern::Dispatch::new()
|
|
14
|
-
.format(move |out, message, record| {
|
|
15
|
-
out.finish(format_args!(
|
|
16
|
-
"[{}][{}] {}",
|
|
17
|
-
record.target(),
|
|
18
|
-
record.level(),
|
|
19
|
-
message
|
|
20
|
-
))
|
|
21
|
-
})
|
|
22
|
-
.level(log::LevelFilter::Info)
|
|
23
|
-
.chain(std::io::stdout())
|
|
24
|
-
.apply()
|
|
25
|
-
.expect("Could not initialize logger");
|
|
26
10
|
let index_html = Asset::get("index.html").unwrap();
|
|
27
11
|
println!("{:?}", std::str::from_utf8(&index_html));
|
|
28
12
|
}
|
examples/rocket.rs
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
#![feature(test, plugin, decl_macro, attr_literals)]
|
|
2
2
|
#![plugin(rocket_codegen)]
|
|
3
|
-
extern crate fern;
|
|
4
|
-
#[macro_use]
|
|
5
|
-
extern crate log;
|
|
6
3
|
extern crate rocket;
|
|
7
4
|
extern crate rocket_contrib;
|
|
8
5
|
#[macro_use]
|
|
@@ -52,18 +49,5 @@ fn dist<'r>(file: PathBuf) -> response::Result<'r> {
|
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
fn main() {
|
|
55
|
-
fern::Dispatch::new()
|
|
56
|
-
.format(move |out, message, record| {
|
|
57
|
-
out.finish(format_args!(
|
|
58
|
-
"[{}][{}] {}",
|
|
59
|
-
record.target(),
|
|
60
|
-
record.level(),
|
|
61
|
-
message
|
|
62
|
-
))
|
|
63
|
-
})
|
|
64
|
-
.level(log::LevelFilter::Info)
|
|
65
|
-
.chain(std::io::stdout())
|
|
66
|
-
.apply()
|
|
67
|
-
.expect("Could not initialize logger");
|
|
68
52
|
rocket::ignite().mount("/", routes![index, dist]).launch();
|
|
69
53
|
}
|