#[repr(transparent)]pub struct RawReportRef<'a> {
ptr: NonNull<ReportData<Erased>>,
_marker: PhantomData<&'a ReportData<Erased>>,
}Expand description
A lifetime-bound pointer to a ReportData that is guaranteed to point
to an initialized instance of a ReportData<C> for some specific C,
though we do not know which actual C it is.
We cannot use a &'a ReportData<C> directly, because that would require
us to know the actual type of the context, which we do not.
§Safety invariants
This reference behaves like a &'a ReportData<C> for some unknown
C and upholds the usual safety invariants of shared references:
- The pointee is properly initialized for the entire lifetime
'a. - The pointee is not mutated for the entire lifetime
'a.
Fields§
§ptr: NonNull<ReportData<Erased>>Pointer to the inner report data
§Safety
The following safety invariants are guaranteed to be upheld as long as this struct exists:
- The pointer must have been created from a
triomphe::Arc<ReportData<C>>for someCusingtriomphe::Arc::into_raw. - The pointer will point to the same
ReportData<C>for the entire lifetime of this object.
_marker: PhantomData<&'a ReportData<Erased>>Marker to tell the compiler that we should
behave the same as a &'a ReportData<Erased>
Implementations§
Source§impl<'a> RawReportRef<'a>
impl<'a> RawReportRef<'a>
Sourcepub(super) fn vtable(self) -> &'static ReportVtable
pub(super) fn vtable(self) -> &'static ReportVtable
Returns a reference to the ReportVtable of this report.
The returned vtable is guaranteed to match the context type stored in
the ReportData.
Sourcepub fn attachments(self) -> &'a Vec<RawAttachment>
pub fn attachments(self) -> &'a Vec<RawAttachment>
Returns the attachments of this report.
Sourcepub unsafe fn context_downcast_unchecked<C: 'static>(self) -> &'a C
pub unsafe fn context_downcast_unchecked<C: 'static>(self) -> &'a C
Downcasts the context to the specified type and returns a reference.
§Safety
The caller must ensure:
- The type
Cmatches the actual context type stored in theReportData
Source§impl<'a> RawReportRef<'a>
impl<'a> RawReportRef<'a>
Sourcepub(super) unsafe fn cast_inner<C>(self) -> &'a ReportData<C>
pub(super) unsafe fn cast_inner<C>(self) -> &'a ReportData<C>
Casts the RawReportRef to a ReportData<C> reference.
§Safety
The caller must ensure:
- The type
Cmatches the actual context type stored in theReportData
Sourcepub(super) fn as_ptr(self) -> *const ReportData<Erased>
pub(super) fn as_ptr(self) -> *const ReportData<Erased>
Returns a NonNull pointer to the ReportData instance.
Sourcepub fn context_type_id(self) -> TypeId
pub fn context_type_id(self) -> TypeId
Returns the TypeId of the context.
Sourcepub fn context_handler_type_id(self) -> TypeId
pub fn context_handler_type_id(self) -> TypeId
Returns the TypeId of the context.
Sourcepub fn context_source(self) -> Option<&'a (dyn Error + 'static)>
pub fn context_source(self) -> Option<&'a (dyn Error + 'static)>
Returns the source of the context using the ContextHandler::source
method specified when the ReportData was created.
Sourcepub fn context_display(self, formatter: &mut Formatter<'_>) -> Result
pub fn context_display(self, formatter: &mut Formatter<'_>) -> Result
Formats the context by using the ContextHandler::display method
specified by the handler used to create the ReportData.
Sourcepub fn context_debug(self, formatter: &mut Formatter<'_>) -> Result
pub fn context_debug(self, formatter: &mut Formatter<'_>) -> Result
Formats the context by using the ContextHandler::debug method
specified by the handler used to create the ReportData.
Sourcepub fn preferred_context_formatting_style(
self,
report_formatting_function: FormattingFunction,
) -> ContextFormattingStyle
pub fn preferred_context_formatting_style( self, report_formatting_function: FormattingFunction, ) -> ContextFormattingStyle
Sourcepub unsafe fn clone_arc(self) -> RawReport
pub unsafe fn clone_arc(self) -> RawReport
Clones the inner triomphe::Arc and returns a new RawReport
pointing to the same data.
§Safety
The caller must ensure:
- All other references to this report are compatible with shared
ownership. Specifically none of them assume that the strong_count is
1.
Sourcepub fn strong_count(self) -> usize
pub fn strong_count(self) -> usize
Gets the strong_count of the inner triomphe::Arc.
Trait Implementations§
Source§impl<'a> Clone for RawReportRef<'a>
impl<'a> Clone for RawReportRef<'a>
Source§fn clone(&self) -> RawReportRef<'a>
fn clone(&self) -> RawReportRef<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more