Trait uucore::error::FromIo

source ·
pub trait FromIo<T> {
    // Required method
    fn map_err_context(self, context: impl FnOnce() -> String) -> T;
}
Expand description

Enables the conversion from std::io::Error to UError and from std::io::Result to UResult.

Required Methods§

source

fn map_err_context(self, context: impl FnOnce() -> String) -> T

Implementations on Foreign Types§

source§

impl<T> FromIo<Result<T, Box<dyn UError + 'static, Global>>> for Result<T>

source§

fn map_err_context(self, context: impl FnOnce() -> String) -> UResult<T>

source§

impl FromIo<Box<UIoError, Global>> for Error

source§

fn map_err_context(self, context: impl FnOnce() -> String) -> Box<UIoError>

source§

impl<T> FromIo<Result<T, Box<dyn UError + 'static, Global>>> for Result<T, Error>

Enables the conversion from Result<T, nix::Error> to UResult<T>.

Examples

use uucore::error::FromIo;
use nix::errno::Errno;

let nix_err = Err::<(), nix::Error>(Errno::EACCES);
let uio_result = nix_err.map_err_context(|| String::from("fix me please!"));

// prints "fix me please!: Permission denied"
println!("{}", uio_result.unwrap_err());
source§

fn map_err_context(self, context: impl FnOnce() -> String) -> UResult<T>

source§

impl FromIo<Box<UIoError, Global>> for ErrorKind

source§

fn map_err_context(self, context: impl FnOnce() -> String) -> Box<UIoError>

Implementors§

source§

impl<T> FromIo<Result<T, Box<dyn UError + 'static, Global>>> for uucore::pipes::Error