ReportVtable

Struct ReportVtable 

Source
pub(super) struct ReportVtable {
    type_id: fn() -> TypeId,
    handler_type_id: fn() -> TypeId,
    drop: unsafe fn(NonNull<ReportData<Erased>>),
    clone_arc: unsafe fn(NonNull<ReportData<Erased>>) -> RawReport,
    strong_count: unsafe fn(NonNull<ReportData<Erased>>) -> usize,
    source: unsafe fn(RawReportRef<'_>) -> Option<&(dyn Error + 'static)>,
    display: unsafe fn(RawReportRef<'_>, &mut Formatter<'_>) -> Result,
    debug: unsafe fn(RawReportRef<'_>, &mut Formatter<'_>) -> Result,
    preferred_context_formatting_style: unsafe fn(RawReportRef<'_>, FormattingFunction, bool) -> ContextFormattingStyle,
}
Expand description

Vtable for type-erased report operations.

Contains function pointers for performing operations on reports without knowing their concrete type at compile time.

Fields§

§type_id: fn() -> TypeId§handler_type_id: fn() -> TypeId§drop: unsafe fn(NonNull<ReportData<Erased>>)§clone_arc: unsafe fn(NonNull<ReportData<Erased>>) -> RawReport§strong_count: unsafe fn(NonNull<ReportData<Erased>>) -> usize§source: unsafe fn(RawReportRef<'_>) -> Option<&(dyn Error + 'static)>§display: unsafe fn(RawReportRef<'_>, &mut Formatter<'_>) -> Result§debug: unsafe fn(RawReportRef<'_>, &mut Formatter<'_>) -> Result§preferred_context_formatting_style: unsafe fn(RawReportRef<'_>, FormattingFunction, bool) -> ContextFormattingStyle

Implementations§

Source§

impl ReportVtable

Source

pub(super) const fn new<C: 'static, H: ContextHandler<C>>() -> &'static Self

Creates a new ReportVtable for the context type C and the handler type H.

Source

pub(super) fn type_id(&self) -> TypeId

Gets the TypeId of the context type that was used to create this ReportVtable.

Source

pub(super) fn handler_type_id(&self) -> TypeId

Gets the TypeId of the handler that was used to create this ReportVtable.

Source

pub(super) unsafe fn drop(&self, ptr: NonNull<ReportData<Erased>>)

Drops the triomphe::Arc<ReportData<C>> instance pointed to by this pointer.

§Safety
Source

pub(super) unsafe fn clone_arc( &self, ptr: NonNull<ReportData<Erased>>, ) -> RawReport

Clones the triomphe::Arc<ReportData<C>> pointed to by this pointer.

§Safety
Source

pub(super) unsafe fn strong_count( &self, ptr: NonNull<ReportData<Erased>>, ) -> usize

Gets the strong count of the triomphe::Arc<ReportData<C>> pointed to by this pointer.

§Safety
Source

pub(super) unsafe fn source<'a>( &self, ptr: RawReportRef<'a>, ) -> Option<&'a (dyn Error + 'static)>

Returns a reference to the source of the error using the H::source function used when creating this ReportVtable.

§Safety

The context type C used when creating this ReportVtable must match the type of the C stored in the ReportData pointed to by the RawReportRef.

Source

pub(super) unsafe fn display<'a>( &self, ptr: RawReportRef<'a>, formatter: &mut Formatter<'_>, ) -> Result

Formats the report using the H::display function used when creating this ReportVtable.

§Safety

The context type C used when creating this ReportVtable must match the type stored in the ReportData.

Source

pub(super) unsafe fn debug<'a>( &self, ptr: RawReportRef<'a>, formatter: &mut Formatter<'_>, ) -> Result

Formats the given RawReportRef using the H::debug function used when creating this ReportVtable.

§Safety

The context type C used when creating this ReportVtable must match the type stored in the ReportData.

Source

pub(super) unsafe fn preferred_context_formatting_style( &self, ptr: RawReportRef<'_>, report_formatting_function: FormattingFunction, report_formatting_alternate: bool, ) -> ContextFormattingStyle

Calls the H::preferred_formatting_style function to get the formatting style preferred by the context when formatted as part of a report.

§Safety

The context type C used when creating this ReportVtable must match the type stored in the ReportData.

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<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.