pub enum ConfigEntry {
Directory(ConfigDir),
File(ConfigFile),
}Expand description
Represents a filesystem entry that is relevant for config files.
Variants§
Implementations§
Source§impl ConfigEntry
impl ConfigEntry
Sourcepub fn dir(path: PathBuf) -> Self
pub fn dir(path: PathBuf) -> Self
Creates a directory-type ConfigEntry from
the given path with no questions asked (no validation on the path).
This is intended for creating root entries.
Sourcepub fn try_from(path: PathBuf) -> Option<Self>
pub fn try_from(path: PathBuf) -> Option<Self>
Creates a ConfigEntry from the given PathBuf, if the path points
to a workable config-related filesystem entry.
Sourcepub fn try_from_with_profile(
path: PathBuf,
known_profile: Option<&str>,
) -> Option<Self>
pub fn try_from_with_profile( path: PathBuf, known_profile: Option<&str>, ) -> Option<Self>
Creates a ConfigEntry from the given PathBuf, if the path points
to a workable config-related filesystem entry, optionally applying the
given known profile name to the config files.
Source§impl ConfigEntry
impl ConfigEntry
Sourcepub fn is_directory(&self) -> bool
pub fn is_directory(&self) -> bool
Reports whether this ConfigEntry is a
directory.
Sourcepub fn is_file(&self) -> bool
pub fn is_file(&self) -> bool
Reports whether this ConfigEntry is a config
file.
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Returns a reference to the internally held file/directory name.
Sourcepub fn applies_to_active_profile(&self) -> bool
pub fn applies_to_active_profile(&self) -> bool
Reports whether this ConfigEntry applies
to the active AppProfile.
Sourcepub fn applies_to(&self, profile: impl AsRef<AppProfile>) -> bool
pub fn applies_to(&self, profile: impl AsRef<AppProfile>) -> bool
Reports whether this ConfigEntry applies to the given AppProfile.
Delegates to the underlying logic for both the directory and the file variants.
Sourcepub fn to_config_file(self) -> Option<ConfigFile>
pub fn to_config_file(self) -> Option<ConfigFile>
Consumes this ConfigEntry and yields only ConfigFiles.
Source§impl ConfigEntry
impl ConfigEntry
Sourcepub fn cd(self) -> ConfigEntryIter ⓘ
pub fn cd(self) -> ConfigEntryIter ⓘ
Iterates over ConfigEntrys that are the immediate children of this
ConfigEntry, if this entry is a directory.
If this entry is a file, yields a Once iterator
over that file.
If this entry is a directory that is associated with a profile — the profile is carried over into all nested entries.
All failure conditions (e.g., non-existing paths, un-readable files) are silently ignored.
This is intended for convenient flat-mapping to move deeper into nested directories, if any.
Sourcepub fn cd_capturing_profile(self) -> ConfigEntryIter ⓘ
pub fn cd_capturing_profile(self) -> ConfigEntryIter ⓘ
Same as cd, but if this entry is a directory, then
instead of carrying over the profile that this directory may be
associated with, captures the profile from this directory’s name.
Sourcepub fn cd_forgetting_profile(self) -> ConfigEntryIter ⓘ
pub fn cd_forgetting_profile(self) -> ConfigEntryIter ⓘ
Same as cd, but if this entry is a directory, then
instead of carrying over the profile that this directory may be
associated with, explicitly “forgets” any associated profile: the
children entries will not be associated with any profile.