pub trait ContextTransformNestedExt<C, T>: Sized {
type Output<D: 'static>;
// Required method
fn context_transform_nested<F, D>(self, f: F) -> Self::Output<D>
where F: FnOnce(C) -> D,
D: ObjectMarkerFor<T> + Display + Debug,
PreformattedContext: ObjectMarkerFor<T>;
}Expand description
Extension trait providing
context_transform_nested on Report
with a Mutable root, and on Result<_, Report<_, Mutable, _>>.
§Examples
use rootcause::prelude::*;
use rootcause_preformat::ContextTransformNestedExt;
#[derive(Debug)]
struct Inner;
#[derive(Debug)]
struct Outer(Inner);
let inner: Report<Inner> = report!(Inner);
let wrapped: Report<Outer> = inner.context_transform_nested(Outer);Required Associated Types§
Sourcetype Output<D: 'static>
type Output<D: 'static>
The output type after transforming the context to D. Either
Report<D, Mutable, T> or Result<V, Report<D, Mutable, T>>. See
context_transform_nested for an
example.
Required Methods§
Sourcefn context_transform_nested<F, D>(self, f: F) -> Self::Output<D>where
F: FnOnce(C) -> D,
D: ObjectMarkerFor<T> + Display + Debug,
PreformattedContext: ObjectMarkerFor<T>,
fn context_transform_nested<F, D>(self, f: F) -> Self::Output<D>where
F: FnOnce(C) -> D,
D: ObjectMarkerFor<T> + Display + Debug,
PreformattedContext: ObjectMarkerFor<T>,
Transforms the context and nests the original report as a preformatted child.
Creates a new parent node with fresh hook data (location, backtrace),
but the original context type is lost—the child becomes
PreformattedContext and cannot be downcast.
§Examples
enum AppError {
Lib(LibError)
}
let lib_report: Report<LibError> = report!(LibError);
let app_report: Report<AppError> = lib_report.context_transform_nested(AppError::Lib);§See Also
context()- Adds new parent, preserves child’s typepreformat_root()- Lower-level operation used internallyexamples/context_methods.rs- Comparison guide
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".