#[repr(transparent)]pub struct RawAttachmentRef<'a> {
ptr: NonNull<AttachmentData<Erased>>,
_marker: PhantomData<&'a AttachmentData<Erased>>,
}Expand description
A lifetime-bound pointer to an AttachmentData that is guaranteed to
point to an initialized instance of an AttachmentData<A> for some
specific A, though we do not know which actual A it is.
We cannot use a &'a AttachmentData<A> directly, because that would
require us to know the actual type of the attachment, which we do not.
Fields§
§ptr: NonNull<AttachmentData<Erased>>Pointer to the inner attachment 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
Box<AttachmentData<A>>for someAusingBox::into_raw. - The pointer will point to the same
AttachmentData<A>for the entire lifetime of this object.
_marker: PhantomData<&'a AttachmentData<Erased>>Marker to tell the compiler that we should
behave the same as a &'a AttachmentData<Erased>
Implementations§
Source§impl<'a> RawAttachmentRef<'a>
impl<'a> RawAttachmentRef<'a>
Sourcepub(super) fn vtable(self) -> &'static AttachmentVtable
pub(super) fn vtable(self) -> &'static AttachmentVtable
Returns a reference to the AttachmentVtable of the
AttachmentData instance.
The returned vtable is guaranteed to be a vtable for the
attachment type stored in the AttachmentData.
Sourcepub unsafe fn attachment_downcast_unchecked<A: 'static>(self) -> &'a A
pub unsafe fn attachment_downcast_unchecked<A: 'static>(self) -> &'a A
Accesses the inner attachment of the AttachmentData instance as a
reference to the specified type.
§Safety
The caller must ensure:
- The type
Amatches the actual attachment type stored in theAttachmentData.
Source§impl<'a> RawAttachmentRef<'a>
impl<'a> RawAttachmentRef<'a>
Sourcepub(super) unsafe fn cast_inner<A>(self) -> &'a AttachmentData<A>
pub(super) unsafe fn cast_inner<A>(self) -> &'a AttachmentData<A>
Casts the RawAttachmentRef to an AttachmentData<A> reference.
§Safety
The caller must ensure:
- The type
Amatches the actual attachment type stored in theAttachmentData.
Sourcepub(super) fn as_ptr(self) -> *const AttachmentData<Erased>
pub(super) fn as_ptr(self) -> *const AttachmentData<Erased>
Returns a NonNull pointer to the AttachmentData instance.
Sourcepub fn attachment_type_id(self) -> TypeId
pub fn attachment_type_id(self) -> TypeId
Returns the TypeId of the attachment.
Sourcepub fn attachment_handler_type_id(self) -> TypeId
pub fn attachment_handler_type_id(self) -> TypeId
Returns the TypeId of the attachment.
Sourcepub fn attachment_display(self, formatter: &mut Formatter<'_>) -> Result
pub fn attachment_display(self, formatter: &mut Formatter<'_>) -> Result
Formats the attachment by using the AttachmentHandler::display
method specified by the handler used to create the
AttachmentData.
Sourcepub fn attachment_debug(self, formatter: &mut Formatter<'_>) -> Result
pub fn attachment_debug(self, formatter: &mut Formatter<'_>) -> Result
Formats the attachment by using the AttachmentHandler::debug method
specified by the handler used to create the AttachmentData.
Sourcepub fn preferred_formatting_style(
self,
report_formatting_function: FormattingFunction,
) -> AttachmentFormattingStyle
pub fn preferred_formatting_style( self, report_formatting_function: FormattingFunction, ) -> AttachmentFormattingStyle
Trait Implementations§
Source§impl<'a> Clone for RawAttachmentRef<'a>
impl<'a> Clone for RawAttachmentRef<'a>
Source§fn clone(&self) -> RawAttachmentRef<'a>
fn clone(&self) -> RawAttachmentRef<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more