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) -> 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) -> AttachmentFormattingStyleImplementations§
Source§impl AttachmentVtable
impl AttachmentVtable
Sourcepub(super) const fn new<A: 'static, H: AttachmentHandler<A>>() -> &'static Self
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.
Sourcepub(super) fn type_id(&self) -> TypeId
pub(super) fn type_id(&self) -> TypeId
Gets the TypeId of the attachment type that was used to create this AttachmentVtable.
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 AttachmentVtable.
Sourcepub(super) unsafe fn drop(&self, ptr: NonNull<AttachmentData<Erased>>)
pub(super) unsafe fn drop(&self, ptr: NonNull<AttachmentData<Erased>>)
Drops the Box<AttachmentData<A>> instance pointed to by this pointer.
§Safety
- The caller must ensure that the pointer comes from a
Box<AttachmentData<A>>, which was turned into a pointer usingBox::into_raw. - The attachment type
Astored in theAttachmentDatamust match theAused when creating thisAttachmentVtable. - After calling this method, the pointer must no longer be used.
Sourcepub(super) unsafe fn display(
&self,
ptr: RawAttachmentRef<'_>,
formatter: &mut Formatter<'_>,
) -> Result
pub(super) unsafe fn display( &self, ptr: RawAttachmentRef<'_>, 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.
Sourcepub(super) unsafe fn debug(
&self,
ptr: RawAttachmentRef<'_>,
formatter: &mut Formatter<'_>,
) -> Result
pub(super) unsafe fn debug( &self, ptr: RawAttachmentRef<'_>, 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.
Sourcepub(super) unsafe fn preferred_formatting_style(
&self,
ptr: RawAttachmentRef<'_>,
report_formatting_function: FormattingFunction,
) -> AttachmentFormattingStyle
pub(super) unsafe fn preferred_formatting_style( &self, ptr: RawAttachmentRef<'_>, report_formatting_function: FormattingFunction, ) -> 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.