pub struct Dir<'a> { /* private fields */ }
Expand description
A directory.
Implementations§
source§impl<'a> Dir<'a>
impl<'a> Dir<'a>
sourcepub fn path(&self) -> &'a Path
pub fn path(&self) -> &'a Path
The full path for this Dir
, relative to the directory passed to
[crate::include_dir!()
].
sourcepub fn files(&self) -> impl Iterator<Item = &'a File<'a>> + 'a
pub fn files(&self) -> impl Iterator<Item = &'a File<'a>> + 'a
Get a list of the files in this directory.
sourcepub fn dirs(&self) -> impl Iterator<Item = &'a Dir<'a>> + 'a
pub fn dirs(&self) -> impl Iterator<Item = &'a Dir<'a>> + 'a
Get a list of the sub-directories inside this directory.
sourcepub fn get_entry<S>(&self, path: S) -> Option<&'a DirEntry<'a>>where
S: AsRef<Path>,
pub fn get_entry<S>(&self, path: S) -> Option<&'a DirEntry<'a>>where S: AsRef<Path>,
Recursively search for a DirEntry
with a particular path.
sourcepub fn get_file<S>(&self, path: S) -> Option<&'a File<'a>>where
S: AsRef<Path>,
pub fn get_file<S>(&self, path: S) -> Option<&'a File<'a>>where S: AsRef<Path>,
Look up a file by name.
sourcepub fn get_dir<S>(&self, path: S) -> Option<&'a Dir<'a>>where
S: AsRef<Path>,
pub fn get_dir<S>(&self, path: S) -> Option<&'a Dir<'a>>where S: AsRef<Path>,
Look up a dir by name.
sourcepub fn contains<S>(&self, path: S) -> boolwhere
S: AsRef<Path>,
pub fn contains<S>(&self, path: S) -> boolwhere S: AsRef<Path>,
Does this directory contain path
?
sourcepub fn extract<S>(&self, base_path: S) -> Result<(), Error>where
S: AsRef<Path>,
pub fn extract<S>(&self, base_path: S) -> Result<(), Error>where S: AsRef<Path>,
Create directories and extract all files to real filesystem.
Creates parent directories of path
if they do not already exist.
Fails if some files already exist.
In case of error, partially extracted directory may remain on the filesystem.