AttachmentVtable

Struct AttachmentVtable 

Source
pub(super) struct AttachmentVtable {
    type_id: fn() -> TypeId,
    handler_type_id: fn() -> TypeId,
    drop: unsafe fn(NonNull<AttachmentData<Erased>>),
    display: unsafe fn(RawAttachmentRef<'_>, &mut Formatter<'_>) -> Result,
    debug: unsafe fn(RawAttachmentRef<'_>, &mut Formatter<'_>) -> Result,
    preferred_formatting_style: unsafe fn(RawAttachmentRef<'_>, FormattingFunction, bool) -> AttachmentFormattingStyle,
}
Expand description

Vtable for type-erased attachment operations.

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

Fields§

§type_id: fn() -> TypeId§handler_type_id: fn() -> TypeId§drop: unsafe fn(NonNull<AttachmentData<Erased>>)§display: unsafe fn(RawAttachmentRef<'_>, &mut Formatter<'_>) -> Result§debug: unsafe fn(RawAttachmentRef<'_>, &mut Formatter<'_>) -> Result§preferred_formatting_style: unsafe fn(RawAttachmentRef<'_>, FormattingFunction, bool) -> AttachmentFormattingStyle

Implementations§

Source§

impl AttachmentVtable

Source

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

Creates a new AttachmentVtable for the attachment type A and the handler type H.

Source

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

Gets the TypeId of the attachment type that was used to create this AttachmentVtable.

Source

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

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

Source

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

Drops the Box<AttachmentData<A>> instance pointed to by this pointer.

§Safety
Source

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

Formats the attachment using the H::display function used when creating this AttachmentVtable.

§Safety

The attachment type A used when creating this AttachmentVtable must match the type stored in the RawAttachmentRef.

Source

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

Formats the attachment using the H::debug function used when creating this AttachmentVtable.

§Safety

The attachment type A used when creating this AttachmentVtable must match the type stored in the RawAttachmentRef.

Source

pub(super) unsafe fn preferred_formatting_style<'a>( &self, ptr: RawAttachmentRef<'a>, report_formatting_function: FormattingFunction, report_formatting_alternate: bool, ) -> AttachmentFormattingStyle

Gets the preferred formatting style using the H::preferred_formatting_style function used when creating this AttachmentVtable.

§Safety

The attachment type A used when creating this AttachmentVtable must match the type stored in the RawAttachmentRef.

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.