pub trait Context<T> {
// Required methods
fn context(self, msg: impl Into<String>) -> Result<T, Error>;
fn with_context<F, S>(self, cb: F) -> Result<T, Error>
where F: Fn() -> S,
S: Into<String>;
}Expand description
Helper trait for creating Error instances.
This trait is inspired by anyhow::Context.
§Examples
use genpdfi_extended::error::{Context as _, Error};
use std::io;
let res: Result<(), io::Error> = Err(io::Error::new(io::ErrorKind::Other, "boom"));
let mapped = res.context("wrapped");
assert!(mapped.is_err());Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.