~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.
2cf5ab28
—
Aleti 6 years ago
Re-doing it a bit so tests & examples both work.
- impl/src/lib.rs +5 -6
- src/lib.rs +0 -4
impl/src/lib.rs
CHANGED
|
@@ -13,8 +13,6 @@ use quote::Tokens;
|
|
|
13
13
|
use std::path::Path;
|
|
14
14
|
use syn::*;
|
|
15
15
|
|
|
16
|
-
extern crate rust_embed_utils;
|
|
17
|
-
use rust_embed_utils as utils;
|
|
18
16
|
|
|
19
17
|
#[cfg(all(debug_assertions, not(feature = "debug-embed")))]
|
|
20
18
|
fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
|
|
@@ -43,8 +41,8 @@ fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
|
|
|
43
41
|
|
|
44
42
|
pub fn iter() -> impl Iterator<Item = std::borrow::Cow<'static, str>> {
|
|
45
43
|
use std::path::Path;
|
|
46
|
-
|
|
44
|
+
extern crate rust_embed_utils;
|
|
47
|
-
get_files(String::from(#folder_path)).map(|e| std::borrow::Cow::from(e.rel_path))
|
|
45
|
+
rust_embed_utils::get_files(String::from(#folder_path)).map(|e| std::borrow::Cow::from(e.rel_path))
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
impl rust_embed::RustEmbed for #ident {
|
|
@@ -61,12 +59,13 @@ fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
|
|
|
61
59
|
|
|
62
60
|
#[cfg(any(not(debug_assertions), feature = "debug-embed"))]
|
|
63
61
|
fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
|
|
62
|
+
extern crate rust_embed_utils;
|
|
64
|
-
use
|
|
63
|
+
//use rust_embed_utils::{get_files, FileEntry};
|
|
65
64
|
|
|
66
65
|
let mut match_values = Vec::<Tokens>::new();
|
|
67
66
|
let mut list_values = Vec::<String>::new();
|
|
68
67
|
|
|
69
|
-
for FileEntry { rel_path, full_canonical_path } in get_files(folder_path) {
|
|
68
|
+
for rust_embed_utils::FileEntry { rel_path, full_canonical_path } in rust_embed_utils::get_files(folder_path) {
|
|
70
69
|
match_values.push(quote! {
|
|
71
70
|
#rel_path => {
|
|
72
71
|
let bytes = &include_bytes!(#full_canonical_path)[..];
|
src/lib.rs
CHANGED
|
@@ -6,10 +6,6 @@ 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;
|
|
10
|
-
#[allow(unused_imports)]
|
|
11
|
-
use rust_embed_utils as utils;
|
|
12
|
-
|
|
13
9
|
/// A directory of binary assets.
|
|
14
10
|
///
|
|
15
11
|
/// They should be embedded into the executable for release builds,
|