#![forbid(unsafe_code)]
#[cfg(feature = "compression")]
#[cfg_attr(feature = "compression", doc(hidden))]
pub use include_flate::flate;
#[cfg(feature = "compression")]
pub use include_flate;
extern crate rust_embed_impl;
pub use rust_embed_impl::*;
#[cfg(feature = "compression")]
pub use rust_embed_utils::EmbeddedCompressedFile;
pub use rust_embed_utils::{EmbeddedFile, Metadata};
#[doc(hidden)]
pub extern crate rust_embed_utils as utils;
pub trait RustEmbed {
#[cfg(feature = "compression")]
fn compressed(file_path: &str) -> Option<EmbeddedCompressedFile>;
fn get(file_path: &str) -> Option<EmbeddedFile>;
fn iter() -> impl Iterator<Item = std::borrow::Cow<'static, str>> + 'static;
}
pub use RustEmbed as Embed;
pub trait DynRustEmbed {
#[cfg(feature = "compression")]
fn compressed(&self, file_path: &str) -> Option<EmbeddedCompressedFile>;
fn get(&self, file_path: &str) -> Option<EmbeddedFile>;
fn names(&self) -> Vec<std::borrow::Cow<'static, str>>;
}
impl<T: RustEmbed> DynRustEmbed for T {
#[cfg(feature = "compression")]
fn compressed(&self, file_path: &str) -> Option<EmbeddedCompressedFile> {
T::compressed(file_path)
}
fn get(&self, file_path: &str) -> Option<EmbeddedFile> {
T::get(file_path)
}
fn names(&self) -> Vec<std::borrow::Cow<'static, str>> {
T::iter().collect()
}
}
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(),
}
}
}