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


d448b57b Peter John

4 years ago
Merge pull request #146 from orhun/master
Files changed (1) hide show
  1. impl/src/lib.rs +4 -0
impl/src/lib.rs CHANGED
@@ -46,6 +46,7 @@ fn embedded(ident: &syn::Ident, folder_path: String, prefix: Option<&str>) -> To
46
46
  quote! {
47
47
  #not_debug_attr
48
48
  impl #ident {
49
+ /// Get an embedded file and its metadata.
49
50
  pub fn get(file_path: &str) -> Option<rust_embed::EmbeddedFile> {
50
51
  #handle_prefix
51
52
  match file_path.replace("\\", "/").as_str() {
@@ -59,6 +60,7 @@ fn embedded(ident: &syn::Ident, folder_path: String, prefix: Option<&str>) -> To
59
60
  items.iter()
60
61
  }
61
62
 
63
+ /// Iterates over the file paths in the folder.
62
64
  pub fn iter() -> impl Iterator<Item = std::borrow::Cow<'static, str>> {
63
65
  Self::names().map(|x| std::borrow::Cow::from(*x))
64
66
  }
@@ -89,6 +91,7 @@ fn dynamic(ident: &syn::Ident, folder_path: String, prefix: Option<&str>) -> Tok
89
91
  quote! {
90
92
  #[cfg(debug_assertions)]
91
93
  impl #ident {
94
+ /// Get an embedded file and its metadata.
92
95
  pub fn get(file_path: &str) -> Option<rust_embed::EmbeddedFile> {
93
96
  #handle_prefix
94
97
 
@@ -96,6 +99,7 @@ fn dynamic(ident: &syn::Ident, folder_path: String, prefix: Option<&str>) -> Tok
96
99
  rust_embed::utils::read_file_from_fs(&file_path).ok()
97
100
  }
98
101
 
102
+ /// Iterates over the file paths in the folder.
99
103
  pub fn iter() -> impl Iterator<Item = std::borrow::Cow<'static, str>> {
100
104
  use std::path::Path;
101
105
  rust_embed::utils::get_files(String::from(#folder_path))