~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.


03e7ed7c Aleti

6 years ago
Move utils to their own package
Cargo.toml CHANGED
@@ -13,6 +13,7 @@ authors = ["pyros2097 <pyros2097@gmail.com>"]
13
13
  [dependencies]
14
14
  walkdir = "2.2.7"
15
15
  rust-embed-impl = { version = "4.5.0", path = "impl"}
16
+ rust-embed-utils = { version = "4.5.0", path = "utils"}
16
17
 
17
18
  actix-web = { version = "0.7", optional = true }
18
19
  mime_guess = { version = "2.0.0-alpha.6", optional = true }
impl/Cargo.toml CHANGED
@@ -14,6 +14,8 @@ authors = ["pyros2097 <pyros2097@gmail.com>"]
14
14
  proc-macro = true
15
15
 
16
16
  [dependencies]
17
+ rust-embed-utils = { version = "4.5.0", path = "../utils"}
18
+
17
19
  syn = "0.11"
18
20
  quote = "0.3"
19
21
  walkdir = "2.2.7"
impl/src/lib.rs CHANGED
@@ -13,7 +13,8 @@ use quote::Tokens;
13
13
  use std::path::Path;
14
14
  use syn::*;
15
15
 
16
+ extern crate rust_embed_utils;
16
- mod utils;
17
+ use rust_embed_utils as utils;
17
18
 
18
19
  #[cfg(all(debug_assertions, not(feature = "debug-embed")))]
19
20
  fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
impl/src/utils.rs DELETED
@@ -1 +0,0 @@
1
- ../../src/utils.rs
src/lib.rs CHANGED
@@ -6,9 +6,9 @@ extern crate walkdir;
6
6
  extern crate rust_embed_impl;
7
7
  pub use rust_embed_impl::*;
8
8
 
9
+ extern crate rust_embed_utils;
9
- #[doc(hidden)]
10
+ #[allow(unused_imports)]
10
- #[cfg(all(debug_assertions, not(feature = "debug-embed")))]
11
- pub mod utils;
11
+ use rust_embed_utils as utils;
12
12
 
13
13
  /// A directory of binary assets.
14
14
  ///
utils/Cargo.toml ADDED
@@ -0,0 +1,17 @@
1
+ [package]
2
+ name = "rust-embed-utils"
3
+ version = "4.5.0"
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
+ readme = "readme.md"
6
+ documentation = "https://docs.rs/rust-embed"
7
+ repository = "https://github.com/pyros2097/rust-embed"
8
+ license = "MIT"
9
+ keywords = ["http", "rocket", "static", "web", "server"]
10
+ categories = ["web-programming::http-server"]
11
+ authors = ["pyros2097 <pyros2097@gmail.com>"]
12
+
13
+ [dependencies]
14
+ walkdir = "2.2.7"
15
+
16
+ [features]
17
+ debug-embed = []
utils/readme.md ADDED
@@ -0,0 +1,3 @@
1
+ # Rust Embed Implementation
2
+
3
+ The utilities used by rust-embed and rust-embed-impl lie here.
src/utils.rs → utils/src/lib.rs RENAMED
@@ -1,15 +1,14 @@
1
+ #[cfg(all(debug_assertions, not(feature = "debug-embed")))]
1
- use std;
2
+ extern crate walkdir;
2
-
3
3
  #[cfg_attr(all(debug_assertions, not(feature = "debug-embed")), allow(unused))]
4
4
  pub struct FileEntry {
5
5
  pub rel_path: String,
6
6
  pub full_canonical_path: String,
7
7
  }
8
8
 
9
+
9
10
  #[cfg_attr(all(debug_assertions, not(feature = "debug-embed")), allow(unused))]
10
11
  pub fn get_files(folder_path: String) -> impl Iterator<Item = FileEntry> {
11
- use std;
12
- use walkdir;
13
12
  walkdir::WalkDir::new(&folder_path)
14
13
  .into_iter()
15
14
  .filter_map(|e| e.ok())