pub struct Slot<'s, T> { /* private fields */ }Expand description
The destination of an in-place decode: uninitialized storage for a T,
borrowed for 's.
The decoder creates one for each call to ReadXDR::read_xdr_in_place;
there is no safe way to make one. Writing a value with Slot::write
consumes the slot and yields the Init the method returns, so a safe
implementation can only fulfil its contract by filling this very slot.
Implementations that initialize the value piecewise write through
Slot::as_mut_ptr and then call Slot::assume_init.
Implementations§
Source§impl<'s, T> Slot<'s, T>
impl<'s, T> Slot<'s, T>
Sourcepub unsafe fn from_raw(ptr: *mut T) -> Slot<'s, T>
pub unsafe fn from_raw(ptr: *mut T) -> Slot<'s, T>
Creates a slot for the storage behind ptr.
§Safety
ptr must be valid for writes, properly aligned, not aliased for
's, and must not hold a value that needs dropping. The slot stands
for that storage alone: an Init obtained from it proves only that
*ptr is initialized, and must not be returned from
ReadXDR::read_xdr_in_place in place of the slot that call was
given.
Sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
A pointer to the storage, for initializing the value piecewise.
Writing through it is sound; reading or dropping is not until the value is initialized.
Sourcepub fn as_uninit_mut(&mut self) -> &mut MaybeUninit<T>
pub fn as_uninit_mut(&mut self) -> &mut MaybeUninit<T>
The storage as MaybeUninit.
Sourcepub unsafe fn assume_init(self) -> Init<'s, T>
pub unsafe fn assume_init(self) -> Init<'s, T>
Declares the slot initialized.
§Safety
The storage must hold a valid T, written through
Slot::as_mut_ptr or Slot::as_uninit_mut.