Enum cnf_lib::environment::Environment
source · pub enum Environment {
Host(Host),
Distrobox(Distrobox),
Toolbx(Toolbx),
}Expand description
All the execution environments known to the applicaiton.
Variants§
Host(Host)
The host system
Distrobox(Distrobox)
A distrobox instance
Toolbx(Toolbx)
A toolbx instance
Implementations§
source§impl Environment
impl Environment
sourcepub async fn output_of(
&self,
cmd: CommandLine
) -> Result<String, ExecutionError>
pub async fn output_of( &self, cmd: CommandLine ) -> Result<String, ExecutionError>
Execute a command in this environment and collect stdout, if possible.
Executes cmd inside this env, collecting all output. If execution finishes successfully,
the stdout is returned as String. Otherwise, an ExecutionError is returned instead.
The ExecutionError type takes care of a lot of boilerplate code that is otherwise necessary
to detect specific error conditions caused by different environments (because they can
produce different output for similar/identical error conditions).
Refer to OutputMatcher for added convenience when trying to recover from a
NonZero error.
Test integration
In conjunction with the Mock type, this function allows
replaying the output of called commands. Use the quick_test!
macro to simulate command outputs inside tests.
pub fn to_json(&self) -> String
Trait Implementations§
source§impl Debug for Environment
impl Debug for Environment
source§impl<'de> Deserialize<'de> for Environment
impl<'de> Deserialize<'de> for Environment
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl Display for Environment
impl Display for Environment
source§impl From<Distrobox> for Environment
impl From<Distrobox> for Environment
source§impl From<Host> for Environment
impl From<Host> for Environment
source§impl From<Toolbx> for Environment
impl From<Toolbx> for Environment
source§impl FromStr for Environment
impl FromStr for Environment
source§impl IsEnvironment for Environment
impl IsEnvironment for Environment
source§impl Ord for Environment
impl Ord for Environment
source§fn cmp(&self, other: &Environment) -> Ordering
fn cmp(&self, other: &Environment) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<Environment> for Environment
impl PartialEq<Environment> for Environment
source§fn eq(&self, other: &Environment) -> bool
fn eq(&self, other: &Environment) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd<Environment> for Environment
impl PartialOrd<Environment> for Environment
source§fn partial_cmp(&self, other: &Environment) -> Option<Ordering>
fn partial_cmp(&self, other: &Environment) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more