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>
impl<'a, T> MAPIUninit<'a, T>
Sourcepub fn new(count: usize) -> Result<Self, MAPIAllocError>
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.
Sourcepub fn chain<P>(
&self,
count: usize,
) -> Result<MAPIUninit<'a, P>, MAPIAllocError>
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.
Sourcepub fn into<P>(self) -> Result<MAPIUninit<'a, P>, MAPIAllocError>
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.
Sourcepub fn iter(&self) -> MAPIUninitIter<'a, T> ⓘ
pub fn iter(&self) -> MAPIUninitIter<'a, T> ⓘ
Get an iterator over the uninitialized elements.
Sourcepub fn uninit(&mut self) -> Result<&mut MaybeUninit<T>, MAPIAllocError>
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.
Sourcepub unsafe fn assume_init(self) -> MAPIBuffer<'a, T>
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.