pub enum ConfigFile {
GenericToml(PathBuf),
GenericYaml(PathBuf),
SpecificToml {
path: PathBuf,
profile: String,
},
SpecificYaml {
path: PathBuf,
profile: String,
},
}Expand description
Represents a single config file.
Variants§
GenericToml(PathBuf)
A file like app.toml.
GenericYaml(PathBuf)
A file like app.yaml / app.yml.
SpecificToml
A file like app.prod.toml.
SpecificYaml
A file like app.prod.yaml / app.prod.yml.
Implementations§
Source§impl ConfigFile
impl ConfigFile
Sourcepub fn try_at(path: PathBuf) -> Option<Self>
pub fn try_at(path: PathBuf) -> Option<Self>
Creates a ConfigFile from the given PathBuf, if the path points
to a workable config file.
Sourcepub fn try_make_with_profile(
path: PathBuf,
known_profile: Option<&str>,
) -> Option<Self>
pub fn try_make_with_profile( path: PathBuf, known_profile: Option<&str>, ) -> Option<Self>
Creates a ConfigFile from the given PathBuf, if the path points
to a workable config file, optionally applying the given known profile
name.
Source§impl ConfigFile
impl ConfigFile
Sourcepub fn is_generic(&self) -> bool
pub fn is_generic(&self) -> bool
Reports whether this ConfigFile is applicable regardless of the
active AppProfile.
Sourcepub fn is_specific(&self) -> bool
pub fn is_specific(&self) -> bool
Reports whether this ConfigFile is applicable only to a particular
AppProfile.
Sourcepub fn profile(&self) -> Option<&str>
pub fn profile(&self) -> Option<&str>
Returns a reference to the internally held profile name (if this variant is specific).
Sourcepub fn applies_to_active_profile(&self) -> bool
pub fn applies_to_active_profile(&self) -> bool
Reports whether this ConfigFile 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 ConfigFile applies to the given AppProfile.
A generic config file (without a profile name in its file name) applies to any profile by default. A specific config file (with a profile name in its file name) applies to the given profile if the profile name matches.
Trait Implementations§
Source§impl Debug for ConfigFile
impl Debug for ConfigFile
Source§impl From<ConfigFile> for File<FileSourceFile, FileFormat>
impl From<ConfigFile> for File<FileSourceFile, FileFormat>
Source§fn from(file: ConfigFile) -> Self
fn from(file: ConfigFile) -> Self
Source§impl From<ConfigFile> for PathBuf
impl From<ConfigFile> for PathBuf
Source§fn from(file: ConfigFile) -> Self
fn from(file: ConfigFile) -> Self
Source§impl Ord for ConfigFile
impl Ord for ConfigFile
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Implements the custom ordering rules for ConfigFile.
First rule is that generics always come before specifics (so that specifics would override generics). After that, both subgroups are ordered by their file path. For specific files, we order by the profile name before we order by the path.