pub struct Dir { /* private fields */ }
Expand description
Represents a directory, which may be embedded or from the filesystem. Provides methods to enumerate and access files and subdirectories. Represents a directory, which may be embedded or from the filesystem. Provides methods to enumerate and access files and subdirectories.
Implementations§
Source§impl Dir
impl Dir
Sourcepub const fn from_embedded(dir: Dir<'static>, path: &'static str) -> Self
pub const fn from_embedded(dir: Dir<'static>, path: &'static str) -> Self
Creates a directory from an embedded include_dir::Dir
and its root path.
Intended for use in tests and advanced scenarios.
Sourcepub fn from_path(path: &Path) -> Self
pub fn from_path(path: &Path) -> Self
Creates a new directory from the given path, relative to the manifest directory at build time. The path can be any valid subdirectory or file path.
Sourcepub fn into_dynamic(self) -> Self
pub fn into_dynamic(self) -> Self
Converts an embedded directory to a dynamic (filesystem-backed) directory if possible. For embedded directories, this will create a Path variant using the embedded root path.
Sourcepub fn auto_dynamic(self) -> Self
pub fn auto_dynamic(self) -> Self
Automatically converts to a dynamic directory if in debug mode (cfg!(debug_assertions)). In release mode, returns self unchanged.
Sourcepub fn from_str(path: &'static str) -> Self
pub fn from_str(path: &'static str) -> Self
Creates a new root directory from the given string path, relative to the manifest directory. The path must be a string literal or static string.
Sourcepub fn is_embedded(&self) -> bool
pub fn is_embedded(&self) -> bool
Returns true if this directory is embedded in the binary.
Sourcepub fn absolute_path(&self) -> &Path
pub fn absolute_path(&self) -> &Path
Returns the absolute path of this directory.
Sourcepub fn entries(&self) -> Vec<DirEntry>
pub fn entries(&self) -> Vec<DirEntry>
Returns all immediate entries (files and subdirectories) in this directory.
Sourcepub fn get_file(&self, name: &str) -> Option<File>
pub fn get_file(&self, name: &str) -> Option<File>
Returns the file with the given name if it exists in this directory. The name is relative to the directory root.