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) -> 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) -> ContextFormattingStyleImplementations§
Source§impl ReportVtable
impl ReportVtable
Sourcepub(super) const fn new<C: 'static, H: ContextHandler<C>>() -> &'static Self
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.
Sourcepub(super) fn type_id(&self) -> TypeId
pub(super) fn type_id(&self) -> TypeId
Gets the TypeId of the context type that was used to create this ReportVtable.
Sourcepub(super) fn handler_type_id(&self) -> TypeId
pub(super) fn handler_type_id(&self) -> TypeId
Gets the TypeId of the handler that was used to create this ReportVtable.
Sourcepub(super) unsafe fn drop(&self, ptr: NonNull<ReportData<Erased>>)
pub(super) unsafe fn drop(&self, ptr: NonNull<ReportData<Erased>>)
Drops the triomphe::Arc<ReportData<C>> instance pointed to by this pointer.
§Safety
- The caller must ensure that the pointer comes from an
triomphe::Arc<ReportData<C>>, which was turned into a pointer usingtriomphe::Arc::into_raw. - The context type
Cstored in theReportDatamust match theCused when creating thisReportVtable. - After calling this method, the pointer must no longer be used.
Sourcepub(super) unsafe fn clone_arc(
&self,
ptr: NonNull<ReportData<Erased>>,
) -> RawReport
pub(super) unsafe fn clone_arc( &self, ptr: NonNull<ReportData<Erased>>, ) -> RawReport
Clones the triomphe::Arc<ReportData<C>> pointed to by this pointer.
§Safety
- The caller must ensure that the pointer comes from an
triomphe::Arc<ReportData<C>>, which was turned into a pointer usingtriomphe::Arc::into_raw. - The context type
Cstored in theReportDatamust match theCused when creating thisReportVtable. - There must be no external assumptions that there is a unique ownership of the
triomphe::Arc.
Sourcepub(super) unsafe fn strong_count(
&self,
ptr: NonNull<ReportData<Erased>>,
) -> usize
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
- The caller must ensure that the pointer comes from an
triomphe::Arc<ReportData<C>>, which was turned into a pointer usingtriomphe::Arc::into_raw. - The context type
Cstored in theReportDatamust match theCused when creating thisReportVtable.
Sourcepub(super) unsafe fn source<'a>(
&self,
ptr: RawReportRef<'a>,
) -> Option<&'a (dyn Error + 'static)>
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.
Sourcepub(super) unsafe fn display(
&self,
ptr: RawReportRef<'_>,
formatter: &mut Formatter<'_>,
) -> Result
pub(super) unsafe fn display( &self, ptr: RawReportRef<'_>, 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.
Sourcepub(super) unsafe fn debug(
&self,
ptr: RawReportRef<'_>,
formatter: &mut Formatter<'_>,
) -> Result
pub(super) unsafe fn debug( &self, ptr: RawReportRef<'_>, 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.
Sourcepub(super) unsafe fn preferred_context_formatting_style(
&self,
ptr: RawReportRef<'_>,
report_formatting_function: FormattingFunction,
) -> ContextFormattingStyle
pub(super) unsafe fn preferred_context_formatting_style( &self, ptr: RawReportRef<'_>, report_formatting_function: FormattingFunction, ) -> 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.