Struct MAPIUninit

Source
pub struct MAPIUninit<'a, T>(/* private fields */)
where
    T: Sized;
Expand description

Wrapper type for an allocation with either sys::MAPIAllocateBuffer or sys::MAPIAllocateMore which has not been initialized yet.

Implementations§

Source§

impl<'a, T> MAPIUninit<'a, T>

Source

pub fn new(count: usize) -> Result<Self, MAPIAllocError>

Create a new allocation with enough room for count elements of type T with a call to sys::MAPIAllocateBuffer. The buffer is freed as soon as the MAPIUninit or MAPIBuffer is dropped.

If you call MAPIUninit::chain to create any more allocations with sys::MAPIAllocateMore, their lifetimes are constrained to the lifetime of this allocation and they will all be freed together in a single call to sys::MAPIFreeBuffer.

Source

pub fn chain<P>( &self, count: usize, ) -> Result<MAPIUninit<'a, P>, MAPIAllocError>

Create a new allocation with enough room for count elements of type P with a call to sys::MAPIAllocateMore. The result is a separate allocation that is not freed until self is dropped at the beginning of the chain.

You may call MAPIUninit::chain on the result as well, they will both share a root allocation created with MAPIUninit::new.

Source

pub fn into<P>(self) -> Result<MAPIUninit<'a, P>, MAPIAllocError>

Convert an uninitialized allocation to another type. You can use this, for example, to perform an allocation with extra space in a &mut [u8] buffer, and then cast that to a specific type. This is useful with the CbNewXXX functions in crate::sized_types.

Source

pub fn iter(&self) -> MAPIUninitIter<'a, T>

Get an iterator over the uninitialized elements.

Source

pub fn uninit(&mut self) -> Result<&mut MaybeUninit<T>, MAPIAllocError>

Get an uninitialized out-parameter with enough room for a single element of type T.

Source

pub unsafe fn assume_init(self) -> MAPIBuffer<'a, T>

Once the buffer is known to be completely filled in, convert this MAPIUninit to a fully initialized MAPIBuffer.

§Safety

Like MaybeUninit, the caller must ensure that the buffer is completely initialized before calling MAPIUninit::assume_init. It is undefined behavior to leave it uninitialized once we start accessing it.

Auto Trait Implementations§

§

impl<'a, T> Freeze for MAPIUninit<'a, T>

§

impl<'a, T> RefUnwindSafe for MAPIUninit<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> !Send for MAPIUninit<'a, T>

§

impl<'a, T> !Sync for MAPIUninit<'a, T>

§

impl<'a, T> Unpin for MAPIUninit<'a, T>

§

impl<'a, T> UnwindSafe for MAPIUninit<'a, T>
where T: RefUnwindSafe,

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.