Trait OutputMapping

Source
pub trait OutputMapping: 'static {
    type Output: 'static;
    type Error: 'static;

    // Required methods
    fn capture_stdout(&self) -> bool;
    fn capture_stderr(&self) -> bool;
    fn map_output(
        self: Box<Self>,
        stdout: Option<Vec<u8>>,
        stderr: Option<Vec<u8>>,
        exit_status: ExitStatus,
    ) -> Result<Self::Output, Self::Error>;
}
Expand description

Trait used to configure what Command::run() returns.

Required Associated Types§

Source

type Output: 'static

The output produced by this command, if it is run and doesn’t fail.

Source

type Error: 'static

The error produced by this command, if it is run and does fail.

Required Methods§

Source

fn capture_stdout(&self) -> bool

Return if stdout needs to be captured for this output mapping map_output function.

This should be a pure function only depending on &self.

Source

fn capture_stderr(&self) -> bool

Return if stderr needs to be captured for this output mapping map_output function.

This should be a pure function only depending on &self.

Source

fn map_output( self: Box<Self>, stdout: Option<Vec<u8>>, stderr: Option<Vec<u8>>, exit_status: ExitStatus, ) -> Result<Self::Output, Self::Error>

The function called once the command’s run completed.

This function is used to convert the captured stdout/stderr to an instance of the given Output type.

If exist code checking is enabled and fails this function will not be called.

If it is disabled this function will be called and the implementation can still decide to fail due to an unexpected/bad exit status.

Implementors§

Source§

impl OutputMapping for ReturnNothing

Source§

impl OutputMapping for ReturnStderr

Source§

impl OutputMapping for ReturnStderrString

Source§

impl OutputMapping for ReturnStdout

Source§

impl OutputMapping for ReturnStdoutAndErr

Source§

impl OutputMapping for ReturnStdoutAndErrStrings

Source§

impl OutputMapping for ReturnStdoutString

Source§

impl<O, E, F> OutputMapping for MapStderr<O, E, F>
where F: FnMut(Vec<u8>) -> Result<O, E>, E: From<CommandExecutionError>,

Source§

type Output = O

Source§

type Error = E

Source§

impl<O, E, F> OutputMapping for MapStderrString<O, E, F>

Source§

type Output = O

Source§

type Error = E

Source§

impl<O, E, F> OutputMapping for MapStdout<O, E, F>
where F: FnMut(Vec<u8>) -> Result<O, E>, E: From<CommandExecutionError>,

Source§

type Output = O

Source§

type Error = E

Source§

impl<O, E, F> OutputMapping for MapStdoutAndErr<O, E, F>

Source§

type Output = O

Source§

type Error = E

Source§

impl<O, E, F> OutputMapping for MapStdoutAndErrStrings<O, E, F>

Source§

type Output = O

Source§

type Error = E

Source§

impl<O, E, F> OutputMapping for MapStdoutString<O, E, F>

Source§

type Output = O

Source§

type Error = E