pub struct OutputConversionError { /* private fields */ }
Expand description

An error produced when attempting to convert Command Output to a custom format (such as Utf8Output).

Produced by methods like CommandExt::output_checked_with and CommandExt::output_checked_utf8.

let mut command = Command::new("sh");
command.args(["-c", "echo puppy doggy"]);
let displayed: Utf8ProgramAndArgs = (&command).into();
let mut output = command.output().unwrap();
output.stdout[5] = 0xc0; // Invalid UTF-8 byte.
let inner: Result<utf8_command::Utf8Output, _> = output.try_into();
let error = OutputConversionError::new(
    Box::new(displayed),
    Box::new(inner.unwrap_err())
);
assert_eq!(
    error.to_string(),
    "Failed to convert `sh` output: \
    Stdout contained invalid utf-8 sequence of 1 bytes from index 5: \
    \"puppy�doggy\\n\""
);

Implementations§

source§

impl OutputConversionError

source

pub fn new( command: Box<dyn CommandDisplay + Send + Sync>, inner: Box<dyn Display + Send + Sync> ) -> Self

Construct a new OutputConversionError.

Trait Implementations§

source§

impl Debug for OutputConversionError

source§

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

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

impl Display for OutputConversionError

source§

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

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

impl From<OutputConversionError> for Error

source§

fn from(error: OutputConversionError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where 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 T
where 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 T
where 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.