ConfigEntry

Enum ConfigEntry 

Source
pub enum ConfigEntry {
    Directory(ConfigDir),
    File(ConfigFile),
}
Expand description

Represents a filesystem entry that is relevant for config files.

Variants§

§

Directory(ConfigDir)

A directory.

§

File(ConfigFile)

A config file.

Implementations§

Source§

impl ConfigEntry

Source

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.

Source

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.

Source

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

Source

pub fn is_directory(&self) -> bool

Reports whether this ConfigEntry is a directory.

Source

pub fn is_file(&self) -> bool

Reports whether this ConfigEntry is a config file.

Source

pub fn path(&self) -> &PathBuf

Returns a reference to the internally held PathBuf.

Source

pub fn name(&self) -> Option<&str>

Returns a reference to the internally held file/directory name.

Source

pub fn applies_to_active_profile(&self) -> bool

Reports whether this ConfigEntry applies to the active AppProfile.

Source

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.

Source

pub fn to_config_file(self) -> Option<ConfigFile>

Consumes this ConfigEntry and yields only ConfigFiles.

Source§

impl ConfigEntry

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for ConfigEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ConfigEntry> for PathBuf

Source§

fn from(file: ConfigEntry) -> Self

Converts to this type from the input type.
Source§

impl Ord for ConfigEntry

Source§

fn cmp(&self, other: &ConfigEntry) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ConfigEntry

Source§

fn eq(&self, other: &ConfigEntry) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for ConfigEntry

Source§

fn partial_cmp(&self, other: &ConfigEntry) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for ConfigEntry

Source§

impl StructuralPartialEq for ConfigEntry

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more