Struct dotfiles_processor::context::Context

source ·
pub struct Context { /* private fields */ }
Expand description

A context represents an environment in which defaults can be overriden, it can be thought of as the context of an individual configuration file to apply.

Notice that contexts can be built on top of one another, so that defaults can be overriden multiple times, and thus have some sort of configuration inheritance.

Implementations§

source§

impl Context

source

pub fn defaults(&self) -> &HashMap<String, Settings>

The default overrides for the current context.

source

pub fn actions(&self) -> &Vec<KnownAction<'static>>

The list of actions parsed from this file.

source

pub fn file(&self) -> &PathBuf

The absolute path to the file to which this context corresponds.

source§

impl Context

source

pub fn subcontext(&self, file: &Path) -> Result<Context, DotfilesError>

source

pub fn get_default(&self, dir: &str, setting: &str) -> Option<&Setting>

source

pub fn parse_file(&mut self) -> Result<(), DotfilesError>

source

pub fn run_actions(context: Context) -> Result<(), DotfilesError>

Runs the actions in this context and consumes the context.

Trait Implementations§

source§

impl<'a> From<Context> for KnownAction<'a>

source§

fn from(value: Context) -> Self

Converts to this type from the input type.
source§

impl TryFrom<&Path> for Context

§

type Error = DotfilesError

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

fn try_from(file_name: &Path) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&str> for Context

§

type Error = DotfilesError

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

fn try_from(file_name: &str) -> Result<Self, Self::Error>

Performs the conversion.

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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

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

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V