Skip to main content

RawAttachmentMut

Struct RawAttachmentMut 

Source
#[repr(transparent)]
pub struct RawAttachmentMut<'a> { ptr: NonNull<AttachmentData<Erased>>, _marker: PhantomData<&'a mut AttachmentData<Erased>>, }
Expand description

A mutable lifetime-bound pointer to an AttachmentData that is guaranteed to be the sole mutable pointer 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 mut 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:

  1. The pointer must have been created from a Box<AttachmentData<A>> for some A using Box::into_raw.
  2. The pointer will point to the same AttachmentData<A> for the entire lifetime of this object.
  3. This pointer represents exclusive mutable access to the AttachmentData for the lifetime 'a with the same semantics as a &'a mut AttachmentData<C>.
§_marker: PhantomData<&'a mut AttachmentData<Erased>>

Marker to tell the compiler that we should behave the same as a &'a mut AttachmentData<Erased>

Implementations§

Source§

impl<'a> RawAttachmentMut<'a>

Source

pub unsafe fn into_attachment_downcast_unchecked<A: 'static>(self) -> &'a mut A

Accesses the inner attachment of the AttachmentData instance as a reference to the specified type.

§Safety

The caller must ensure:

  1. The type A matches the actual attachment type stored in the AttachmentData.
Source§

impl<'a> RawAttachmentMut<'a>

Source

pub(super) unsafe fn cast_inner<A>(self) -> &'a mut AttachmentData<A>

Casts the RawAttachmentMut to an AttachmentData<A> mutable reference.

§Safety

The caller must ensure:

  1. The type A matches the actual attachment type stored in the AttachmentData.
Source

pub fn reborrow<'b>(&'b mut self) -> RawAttachmentMut<'b>

Reborrows the mutable reference to the AttachmentData with a shorter lifetime.

Source

pub fn as_ref<'b: 'a>(&'b self) -> RawAttachmentRef<'b>

Returns a reference to the AttachmentData instance.

Source

pub fn into_ref(self) -> RawAttachmentRef<'a>

Consumes the mutable reference and returns an immutable one with the same lifetime.

Auto Trait Implementations§

§

impl<'a> Freeze for RawAttachmentMut<'a>

§

impl<'a> RefUnwindSafe for RawAttachmentMut<'a>

§

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

§

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

§

impl<'a> Unpin for RawAttachmentMut<'a>

§

impl<'a> !UnwindSafe for RawAttachmentMut<'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> 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.