RawAttachmentRef

Struct RawAttachmentRef 

Source
#[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

§_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>

Source

pub(super) fn vtable(self) -> &'static AttachmentVtable

Returns a reference to the AttachmentVtable of the AttachmentData instance.

Source

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 that the type A matches the actual attachment type stored in the AttachmentData.

Source§

impl<'a> RawAttachmentRef<'a>

Source

pub(super) unsafe fn cast_inner<A: CastTo>( self, ) -> &'a AttachmentData<A::Target>

Casts the RawAttachmentRef to an AttachmentData<A> reference.

§Safety

The caller must ensure that the type A matches the actual attachment type stored in the AttachmentData.

Source

pub(super) fn as_ptr(self) -> *const AttachmentData<Erased>

Returns a NonNull pointer to the AttachmentData instance.

Source

pub fn attachment_type_id(self) -> TypeId

Returns the TypeId of the attachment.

Source

pub fn attachment_handler_type_id(self) -> TypeId

Returns the TypeId of the attachment.

Source

pub fn attachment_downcast<A: 'static>(self) -> Option<&'a A>

Checks if the type of the attachment matches the specified type and returns a reference to it if it does.

Source

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.

Source

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.

Source

pub fn preferred_formatting_style( self, report_formatting_function: FormattingFunction, ) -> AttachmentFormattingStyle

The formatting style preferred by the attachment when formatted as part of a report.

§Arguments
  • report_formatting_function: Whether the report in which this attachment will be embedded is being formatted using Display formatting or Debug

Trait Implementations§

Source§

impl<'a> Clone for RawAttachmentRef<'a>

Source§

fn clone(&self) -> RawAttachmentRef<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for RawAttachmentRef<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for RawAttachmentRef<'a>

§

impl<'a> RefUnwindSafe for RawAttachmentRef<'a>

§

impl<'a> !Send for RawAttachmentRef<'a>

§

impl<'a> !Sync for RawAttachmentRef<'a>

§

impl<'a> Unpin for RawAttachmentRef<'a>

§

impl<'a> UnwindSafe for RawAttachmentRef<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.