Struct conch_runtime::env::VarRestorer [−][src]
pub struct VarRestorer<E: ?Sized> where
E: VariableEnvironment, { /* fields omitted */ }
Maintains a state of all variable definitions that have been modified so that they can be restored later.
Note: the caller should take care that a restorer instance is always called with the same environment for its entire lifetime. Using different environments with the same restorer instance will undoubtedly do the wrong thing eventually, and no guarantees can be made.
Methods
impl<E: ?Sized> VarRestorer<E> where
E: VariableEnvironment, [src]
impl<E: ?Sized> VarRestorer<E> where
E: VariableEnvironment, pub fn new() -> Self[src]
pub fn new() -> SelfCreate a new wrapper.
pub fn with_capacity(capacity: usize) -> Self[src]
pub fn with_capacity(capacity: usize) -> SelfCreate a new wrapper and reserve capacity for backing up the previous file descriptors of the environment.
pub fn restore(self, env: &mut E) where
E: ExportedVariableEnvironment + UnsetVariableEnvironment, [src]
pub fn restore(self, env: &mut E) where
E: ExportedVariableEnvironment + UnsetVariableEnvironment, : use the VarEnvRestorer trait instead
Restore all variable definitions to their original state.
impl<E: ?Sized> VarRestorer<E> where
E: ExportedVariableEnvironment,
E::VarName: Clone,
E::Var: Clone, [src]
impl<E: ?Sized> VarRestorer<E> where
E: ExportedVariableEnvironment,
E::VarName: Clone,
E::Var: Clone, pub fn set_exported_var(
&mut self,
name: E::VarName,
val: E::Var,
exported: bool,
env: &mut E
)[src]
pub fn set_exported_var(
&mut self,
name: E::VarName,
val: E::Var,
exported: bool,
env: &mut E
): use the VarEnvRestorer trait instead
Backup and set the value of some variable, maintaining its status as an environment variable if previously set as such.
pub fn unset_var(&mut self, name: E::VarName, env: &mut E) where
E: UnsetVariableEnvironment, [src]
pub fn unset_var(&mut self, name: E::VarName, env: &mut E) where
E: UnsetVariableEnvironment, : use the VarEnvRestorer trait instead
Backup and unset the value of some variable (including environment variables).
pub fn backup(&mut self, key: E::VarName, env: &E)[src]
pub fn backup(&mut self, key: E::VarName, env: &E): use the VarEnvRestorer trait instead
Backs up the original value of specified variable.
The original value of the variable is the one the environment held before it was passed into this wrapper. That is, if a variable is backed up multiple times, only the value before the first call could be restored later.
Trait Implementations
impl<E: Clone + ?Sized> Clone for VarRestorer<E> where
E: VariableEnvironment,
E::VarName: Clone,
E::Var: Clone, [src]
impl<E: Clone + ?Sized> Clone for VarRestorer<E> where
E: VariableEnvironment,
E::VarName: Clone,
E::Var: Clone, fn clone(&self) -> VarRestorer<E>[src]
fn clone(&self) -> VarRestorer<E>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl<E: ?Sized> Eq for VarRestorer<E> where
E: VariableEnvironment,
E::VarName: Eq,
E::Var: Eq, [src]
impl<E: ?Sized> Eq for VarRestorer<E> where
E: VariableEnvironment,
E::VarName: Eq,
E::Var: Eq, impl<E: ?Sized> PartialEq<Self> for VarRestorer<E> where
E: VariableEnvironment,
E::VarName: Eq,
E::Var: Eq, [src]
impl<E: ?Sized> PartialEq<Self> for VarRestorer<E> where
E: VariableEnvironment,
E::VarName: Eq,
E::Var: Eq, fn eq(&self, other: &Self) -> bool[src]
fn eq(&self, other: &Self) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl<E: ?Sized> Debug for VarRestorer<E> where
E: VariableEnvironment,
E::VarName: Debug,
E::Var: Debug, [src]
impl<E: ?Sized> Debug for VarRestorer<E> where
E: VariableEnvironment,
E::VarName: Debug,
E::Var: Debug, fn fmt(&self, fmt: &mut Formatter) -> Result[src]
fn fmt(&self, fmt: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<E: ?Sized> Default for VarRestorer<E> where
E: VariableEnvironment, [src]
impl<E: ?Sized> Default for VarRestorer<E> where
E: VariableEnvironment, impl<E: ?Sized> VarEnvRestorer<E> for VarRestorer<E> where
E: ExportedVariableEnvironment + UnsetVariableEnvironment,
E::VarName: Clone,
E::Var: Clone, [src]
impl<E: ?Sized> VarEnvRestorer<E> for VarRestorer<E> where
E: ExportedVariableEnvironment + UnsetVariableEnvironment,
E::VarName: Clone,
E::Var: Clone, fn reserve(&mut self, additional: usize)[src]
fn reserve(&mut self, additional: usize)Reserves capacity for at least additional more variables to be backed up.
fn set_exported_var(
&mut self,
name: E::VarName,
val: E::Var,
exported: bool,
env: &mut E
)[src]
fn set_exported_var(
&mut self,
name: E::VarName,
val: E::Var,
exported: bool,
env: &mut E
): Use VarEnvRestorer2::set_exported_var2 instead
Backup and set the value of some variable (and its exported status).
fn unset_var(&mut self, name: E::VarName, env: &mut E)[src]
fn unset_var(&mut self, name: E::VarName, env: &mut E)Backup and unset the value of some variable (including environment variables).
fn backup(&mut self, key: E::VarName, env: &E)[src]
fn backup(&mut self, key: E::VarName, env: &E)Backs up the original value of specified variable. Read more
fn restore(&mut self, env: &mut E)[src]
fn restore(&mut self, env: &mut E)Restore all variable definitions to their original state.
impl<E: ?Sized> VarEnvRestorer2<E> for VarRestorer<E> where
E: ExportedVariableEnvironment + UnsetVariableEnvironment,
E::VarName: Clone,
E::Var: Clone, [src]
impl<E: ?Sized> VarEnvRestorer2<E> for VarRestorer<E> where
E: ExportedVariableEnvironment + UnsetVariableEnvironment,
E::VarName: Clone,
E::Var: Clone, Auto Trait Implementations
impl<E: ?Sized> Send for VarRestorer<E> where
<E as VariableEnvironment>::Var: Send,
<E as VariableEnvironment>::VarName: Send,
impl<E: ?Sized> Send for VarRestorer<E> where
<E as VariableEnvironment>::Var: Send,
<E as VariableEnvironment>::VarName: Send, impl<E: ?Sized> Sync for VarRestorer<E> where
<E as VariableEnvironment>::Var: Sync,
<E as VariableEnvironment>::VarName: Sync,
impl<E: ?Sized> Sync for VarRestorer<E> where
<E as VariableEnvironment>::Var: Sync,
<E as VariableEnvironment>::VarName: Sync,