Skip to main content

ContextTransformNestedExt

Trait ContextTransformNestedExt 

Source
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§

Source

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§

Source

fn context_transform_nested<F, D>(self, f: F) -> Self::Output<D>

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

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<C, T> ContextTransformNestedExt<C, T> for Report<C, Mutable, T>

Source§

type Output<D: 'static> = Report<D, Mutable, T>

Source§

fn context_transform_nested<F, D>(self, f: F) -> Report<D, Mutable, T>

Source§

impl<V, C, T> ContextTransformNestedExt<C, T> for Result<V, Report<C, Mutable, T>>

Source§

type Output<D: 'static> = Result<V, Report<D, Mutable, T>>

Source§

fn context_transform_nested<F, D>( self, f: F, ) -> Result<V, Report<D, Mutable, T>>

Implementors§