1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#[cfg(all(debug_assertions, not(feature = "debug-embed")))]
extern crate walkdir;
#[cfg(feature = "compression")]
extern crate include_flate;
#[cfg(feature = "compression")]
#[cfg_attr(feature = "compression", doc(hidden))]
pub use include_flate::flate;
#[allow(unused_imports)]
#[macro_use]
extern crate rust_embed_impl;
pub use rust_embed_impl::*;
#[doc(hidden)]
#[cfg(all(debug_assertions, not(feature = "debug-embed")))]
pub extern crate rust_embed_utils as utils;
pub trait RustEmbed {
fn get(file_path: &str) -> Option<std::borrow::Cow<'static, [u8]>>;
fn iter() -> Filenames;
}
pub enum Filenames {
#[cfg(any(not(debug_assertions), feature = "debug-embed"))]
Embedded(std::slice::Iter<'static, &'static str>),
#[cfg(all(debug_assertions, not(feature = "debug-embed")))]
Dynamic(Box<dyn Iterator<Item = std::borrow::Cow<'static, str>>>),
}
impl Iterator for Filenames {
type Item = std::borrow::Cow<'static, str>;
fn next(&mut self) -> Option<Self::Item> {
match self {
#[cfg(any(not(debug_assertions), feature = "debug-embed"))]
Filenames::Embedded(names) => names.next().map(|x| std::borrow::Cow::from(*x)),
#[cfg(all(debug_assertions, not(feature = "debug-embed")))]
Filenames::Dynamic(boxed) => boxed.next(),
}
}
}