Skip to main content

Slot

Struct Slot 

Source
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>

Source

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.

Source

pub fn write(self, value: T) -> Init<'s, T>

Writes value into the slot.

Source

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.

Source

pub fn as_uninit_mut(&mut self) -> &mut MaybeUninit<T>

The storage as MaybeUninit.

Source

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.

Auto Trait Implementations§

§

impl<'s, T> !UnwindSafe for Slot<'s, T>

§

impl<'s, T> Freeze for Slot<'s, T>
where &'s mut MaybeUninit<T>: Freeze,

§

impl<'s, T> RefUnwindSafe for Slot<'s, T>
where &'s mut MaybeUninit<T>: RefUnwindSafe,

§

impl<'s, T> Send for Slot<'s, T>
where &'s mut MaybeUninit<T>: Send,

§

impl<'s, T> Sync for Slot<'s, T>
where &'s mut MaybeUninit<T>: Sync,

§

impl<'s, T> Unpin for Slot<'s, T>
where &'s mut MaybeUninit<T>: Unpin,

§

impl<'s, T> UnsafeUnpin for Slot<'s, T>
where &'s mut MaybeUninit<T>: UnsafeUnpin,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> StaticIfNoAlloc for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.