Skip to main content

PreformatRootExt

Trait PreformatRootExt 

Source
pub trait PreformatRootExt<C, T>: Sized {
    // Required method
    fn preformat_root(self) -> (C, Report<PreformattedContext, Mutable, T>)
       where PreformattedContext: ObjectMarkerFor<T>;
}
Expand description

Extension trait providing preformat_root on Report with a Mutable root.

§Examples

use rootcause::prelude::*;
use rootcause_preformat::{PreformatRootExt, PreformattedContext};

#[derive(Debug)]
struct Boom;

let report: Report<Boom> = report!(Boom);
let (_context, _preformatted): (Boom, Report<PreformattedContext>) = report.preformat_root();

Required Methods§

Source

fn preformat_root(self) -> (C, Report<PreformattedContext, Mutable, T>)

Extracts the context and returns it with a preformatted version of the report.

Returns a tuple: the original typed context and a new report with PreformattedContext containing the string representation. The preformatted report maintains the same structure (children and attachments). Useful when you need the typed value for processing and the formatted version for display.

This is a lower-level method primarily for custom transformation logic. Most users should use context_transform_nested instead.

See also: preformat (formats entire hierarchy), into_parts (extracts without formatting), current_context (reference without extraction).

§Examples
struct MyError {
    code: u32
}

let report: Report<MyError> = report!(MyError { code: 500 });
let (context, preformatted): (MyError, Report<PreformattedContext>) = report.preformat_root();

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

Implementors§