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]
E: VariableEnvironment,
fn new() -> Self
[src]
Create a new wrapper.
fn with_capacity(capacity: usize) -> Self
[src]
Create a new wrapper and reserve capacity for backing up the previous file descriptors of the environment.
fn restore(self, env: &mut E) where
E: ExportedVariableEnvironment + UnsetVariableEnvironment,
[src]
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]
E: ExportedVariableEnvironment,
E::VarName: Clone,
E::Var: Clone,
fn set_exported_var(
&mut self,
name: E::VarName,
val: E::Var,
exported: bool,
env: &mut E
)
[src]
&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.
fn unset_var(&mut self, name: E::VarName, env: &mut E) where
E: UnsetVariableEnvironment,
[src]
E: UnsetVariableEnvironment,
: use the VarEnvRestorer
trait instead
Backup and unset the value of some variable (including environment variables).
fn backup(&mut self, key: E::VarName, env: &E)
[src]
: 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]
E: VariableEnvironment,
E::VarName: Clone,
E::Var: Clone,
fn clone(&self) -> VarRestorer<E>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<E: ?Sized> Eq for VarRestorer<E> where
E: VariableEnvironment,
E::VarName: Eq,
E::Var: Eq,
[src]
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]
E: VariableEnvironment,
E::VarName: Eq,
E::Var: Eq,
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<E: ?Sized> Debug for VarRestorer<E> where
E: VariableEnvironment,
E::VarName: Debug,
E::Var: Debug,
[src]
E: VariableEnvironment,
E::VarName: Debug,
E::Var: Debug,
impl<E: ?Sized> Default for VarRestorer<E> where
E: VariableEnvironment,
[src]
E: VariableEnvironment,
impl<E: ?Sized> VarEnvRestorer<E> for VarRestorer<E> where
E: ExportedVariableEnvironment + UnsetVariableEnvironment,
E::VarName: Clone,
E::Var: Clone,
[src]
E: ExportedVariableEnvironment + UnsetVariableEnvironment,
E::VarName: Clone,
E::Var: Clone,
fn reserve(&mut self, additional: usize)
[src]
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]
&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]
Backup and unset the value of some variable (including environment variables).
fn backup(&mut self, key: E::VarName, env: &E)
[src]
Backs up the original value of specified variable. Read more
fn restore(&mut self, env: &mut E)
[src]
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]
E: ExportedVariableEnvironment + UnsetVariableEnvironment,
E::VarName: Clone,
E::Var: Clone,