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 for Environment
impl PartialEq for Environment
Source§impl PartialOrd for Environment
impl PartialOrd for Environment
Source§impl Serialize for Environment
impl Serialize for Environment
impl Eq for Environment
impl StructuralPartialEq for Environment
Auto Trait Implementations§
impl Freeze for Environment
impl RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl UnwindSafe for Environment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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