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
- The original type’s
TypeId(accessible viaoriginal_type_id) - Preformatted
Displayoutput as aString - Preformatted
Debugoutput as aString - Preferred formatting styles for both
DisplayandDebug
§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
impl PreformattedAttachment
Sourcepub fn original_type_id(&self) -> TypeId
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§
impl Freeze for PreformattedAttachment
impl RefUnwindSafe for PreformattedAttachment
impl Send for PreformattedAttachment
impl Sync for PreformattedAttachment
impl Unpin for PreformattedAttachment
impl UnsafeUnpin for PreformattedAttachment
impl UnwindSafe for PreformattedAttachment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more