#[repr(transparent)]pub struct RawAttachment {
ptr: NonNull<AttachmentData<Erased>>,
}Expand description
A 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.
However, the pointer is allowed to transition into a non-initialized state
inside the RawAttachment::drop method.
The pointer is guaranteed to have been created using Box::into_raw.
We cannot use a Box<AttachmentData<A>> directly, because that does not
allow us to type-erase the A.
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.
Implementations§
Source§impl RawAttachment
impl RawAttachment
Sourcepub fn new<A, H>(attachment: A) -> Selfwhere
A: 'static,
H: AttachmentHandler<A>,
pub fn new<A, H>(attachment: A) -> Selfwhere
A: 'static,
H: AttachmentHandler<A>,
Creates a new RawAttachment with the specified handler and
attachment.
The returned attachment will embed the specified attachment and use the specified handler for all operations.
Sourcepub fn as_ref(&self) -> RawAttachmentRef<'_>
pub fn as_ref(&self) -> RawAttachmentRef<'_>
Returns a reference to the AttachmentData instance.