~repos /rust-embed

#rust#proc-macro#http

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.


d7c60d33 Paolo Barbolini

5 years ago
examples: import RustEmbed directly instead of using #[macro_use]
examples/actix.rs CHANGED
@@ -1,11 +1,12 @@
1
1
  extern crate actix_web;
2
- #[macro_use]
3
- extern crate rust_embed;
4
2
  extern crate mime_guess;
3
+ extern crate rust_embed;
5
4
 
6
5
  use actix_web::body::Body;
7
6
  use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};
8
7
  use mime_guess::from_path;
8
+ use rust_embed::RustEmbed;
9
+
9
10
  use std::borrow::Cow;
10
11
 
11
12
  #[derive(RustEmbed)]
examples/basic.rs CHANGED
@@ -1,6 +1,7 @@
1
- #[macro_use]
2
1
  extern crate rust_embed;
3
2
 
3
+ use rust_embed::RustEmbed;
4
+
4
5
  #[derive(RustEmbed)]
5
6
  #[folder = "examples/public/"]
6
7
  struct Asset;
examples/rocket.rs CHANGED
@@ -1,11 +1,12 @@
1
1
  #![feature(decl_macro, proc_macro_hygiene)]
2
2
  #[macro_use]
3
3
  extern crate rocket;
4
- #[macro_use]
5
4
  extern crate rust_embed;
6
5
 
7
6
  use rocket::http::{ContentType, Status};
8
7
  use rocket::response;
8
+ use rust_embed::RustEmbed;
9
+
9
10
  use std::ffi::OsStr;
10
11
  use std::io::Cursor;
11
12
  use std::path::PathBuf;
examples/warp.rs CHANGED
@@ -1,12 +1,13 @@
1
1
  #![deny(warnings)]
2
2
 
3
- #[macro_use]
4
3
  extern crate rust_embed;
5
4
  extern crate warp;
6
5
 
7
- use std::borrow::Cow;
6
+ use rust_embed::RustEmbed;
8
7
  use warp::{filters::path::Tail, http::Response, Filter, Rejection, Reply};
9
8
 
9
+ use std::borrow::Cow;
10
+
10
11
  #[derive(RustEmbed)]
11
12
  #[folder = "examples/public/"]
12
13
  struct Asset;
readme.md CHANGED
@@ -97,8 +97,7 @@ Compress each file when embedding into the binary. Compression is done via [`inc
97
97
  ## Usage
98
98
 
99
99
  ```rust
100
- #[macro_use]
101
- extern crate rust_embed;
100
+ use rust_embed::RustEmbed;
102
101
 
103
102
  #[derive(RustEmbed)]
104
103
  #[folder = "examples/public/"]
src/lib.rs CHANGED
@@ -23,8 +23,8 @@ pub extern crate rust_embed_utils as utils;
23
23
  ///
24
24
  /// This trait is meant to be derived like so:
25
25
  /// ```
26
- /// #[macro_use]
27
- /// extern crate rust_embed;
26
+ /// use rust_embed::RustEmbed;
27
+ ///
28
28
  /// #[derive(RustEmbed)]
29
29
  /// #[folder = "examples/public/"]
30
30
  /// struct Asset;
tests/interpolated_path.rs CHANGED
@@ -1,5 +1,4 @@
1
- #[macro_use]
2
- extern crate rust_embed;
1
+ use rust_embed::RustEmbed;
3
2
 
4
3
  /// Test doc comment
5
4
  #[derive(RustEmbed)]
tests/lib.rs CHANGED
@@ -1,5 +1,4 @@
1
- #[macro_use]
2
- extern crate rust_embed;
1
+ use rust_embed::RustEmbed;
3
2
 
4
3
  /// Test doc comment
5
4
  #[derive(RustEmbed)]