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

source

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.

source

pub fn to_json(&self) -> String

Trait Implementations§

source§

impl Debug for Environment

source§

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

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

impl<'de> Deserialize<'de> for Environment

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Environment

source§

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

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

impl From<Distrobox> for Environment

source§

fn from(value: Distrobox) -> Self

Converts to this type from the input type.
source§

impl From<Host> for Environment

source§

fn from(value: Host) -> Self

Converts to this type from the input type.
source§

impl From<Toolbx> for Environment

source§

fn from(value: Toolbx) -> Self

Converts to this type from the input type.
source§

impl FromStr for Environment

§

type Err = SerializationError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl IsEnvironment for Environment

§

type Err = Error

source§

fn exists(&self) -> bool

Returns true if the given Env is available at all. Read more
source§

fn execute(&self, command: CommandLine) -> Result<Command, Self::Err>

Execute a command within this environment Read more
source§

impl Ord for Environment

source§

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

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

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

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

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

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

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

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

impl PartialEq<Environment> for Environment

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Environment> for Environment

source§

fn partial_cmp(&self, other: &Environment) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Environment

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Environment

source§

impl StructuralEq for Environment

source§

impl StructuralPartialEq for Environment

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,