Skip to main content

PreformattedAttachment

Struct PreformattedAttachment 

Source
pub struct PreformattedAttachment { /* private fields */ }
Expand description

An attachment that has been preformatted into Strings for both Display and Debug.

This type stores the formatted output of an attachment along with metadata about the original type and preferred formatting styles. It’s created automatically by PreformatReportExt::preformat and should not typically be constructed manually.

§Stored Information

§Examples

use rootcause::prelude::*;
use rootcause_preformat::PreformatReportExt;

// When a report is preformatted, all attachments become PreformattedAttachment
let report: Report = report!("error").attach("some data");
let preformatted = report.preformat();

// All attachments in a preformatted report are PreformattedAttachment
// They preserve information about their original types
for attachment in preformatted.attachments().iter() {
    // Each attachment remembers its original type through original_type_id()
    let _original_type = attachment.inner_type_id();
}

Implementations§

Source§

impl PreformattedAttachment

Source

pub fn original_type_id(&self) -> TypeId

Get the TypeId of the original attachment type before it was preformatted.

This can be useful for debugging or for implementing custom logic based on the original attachment type, even though the actual type has been erased.

§Examples
use rootcause::prelude::*;
use rootcause_preformat::{PreformatReportExt, PreformattedAttachment};

let report: Report = report!("error").attach(42u32);
let preformatted = report.preformat();

// After preformatting, all attachments are PreformattedAttachment
// They preserve the original type information
for attachment in preformatted.attachments().iter() {
    // Each PreformattedAttachment can tell you what type it originally was
    if let Some(preformatted) = attachment.downcast_inner::<PreformattedAttachment>() {
        let original_type = preformatted.original_type_id();
        // Can check if it was a specific type, e.g.:
        // if original_type == TypeId::of::<u32>() { ... }
    }
}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<O> ObjectMarkerFor<Local> for O
where O: 'static,

Source§

impl<O> ObjectMarkerFor<SendSync> for O
where O: 'static + Send + Sync,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.