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§
Sourcefn map_err_context(self, context: impl FnOnce() -> String) -> T
fn map_err_context(self, context: impl FnOnce() -> String) -> T
Map the error context of an std::io::Error or std::io::Result to a custom error
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T> FromIo<Result<T, Box<dyn UError>>> for Result<T, Error>
Available on Unix only.Enables the conversion from Result<T, nix::Error> to UResult<T>.
impl<T> FromIo<Result<T, Box<dyn UError>>> for Result<T, Error>
Available on Unix only.
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());