pub struct __Arena(/* private fields */);
Expand description
Implements a memory arena allocator to be used with the Fuchsia Driver Runtime when sending and receiving from channels.
Implementations§
Source§impl Arena
impl Arena
Sourcepub fn contains_ptr<T>(&self, ptr: &T) -> boolwhere
T: ?Sized,
pub fn contains_ptr<T>(&self, ptr: &T) -> boolwhere
T: ?Sized,
Returns true if the allocation pointed to was made by this arena
Sourcepub fn contains<T>(&self, item: &ArenaBox<'_, T>) -> boolwhere
T: ?Sized,
pub fn contains<T>(&self, item: &ArenaBox<'_, T>) -> boolwhere
T: ?Sized,
Returns true if the allocation was made by this arena
Sourcepub fn insert_uninit<T>(&self) -> ArenaBox<'_, MaybeUninit<T>>
pub fn insert_uninit<T>(&self) -> ArenaBox<'_, MaybeUninit<T>>
Inserts a MaybeUninit
object and returns the ArenaBox
of it.
Sourcepub fn insert_uninit_slice<T>(
&self,
len: usize,
) -> ArenaBox<'_, [MaybeUninit<T>]>
pub fn insert_uninit_slice<T>( &self, len: usize, ) -> ArenaBox<'_, [MaybeUninit<T>]>
Inserts a slice of MaybeUninit
objects of len len
§Panics
Panics if an array [T; n]
is too large to be allocated.
Sourcepub fn insert<T>(&self, obj: T) -> ArenaBox<'_, T>
pub fn insert<T>(&self, obj: T) -> ArenaBox<'_, T>
Moves obj
of type T
into the arena and returns an ArenaBox
containing the moved value.
Sourcepub fn insert_slice<T>(&self, slice: &[T]) -> ArenaBox<'_, [T]>where
T: Clone,
pub fn insert_slice<T>(&self, slice: &[T]) -> ArenaBox<'_, [T]>where
T: Clone,
Copies the slice into the arena and returns an ArenaBox
containing
the copied values.
Sourcepub unsafe fn assume_unchecked<T>(&self, ptr: NonNull<T>) -> ArenaBox<'_, T>where
T: ?Sized,
pub unsafe fn assume_unchecked<T>(&self, ptr: NonNull<T>) -> ArenaBox<'_, T>where
T: ?Sized,
Returns an ArenaBox for the pointed to object, assuming that it is part of this arena.
§Safety
This does not verify that the pointer came from this arena, so the caller is responsible for verifying that.
Sourcepub unsafe fn assume<T>(&self, ptr: NonNull<T>) -> ArenaBox<'_, T>where
T: ?Sized,
pub unsafe fn assume<T>(&self, ptr: NonNull<T>) -> ArenaBox<'_, T>where
T: ?Sized,
Returns an ArenaBox
for the pointed to object, verifying that it
is a part of this arena in the process.
§Panics
This function panics if the given pointer is not in this Arena
.
§Safety
The caller is responsible for ensuring that only one ArenaBox
is constructed
for a given pointer, and that the pointer originated from an ArenaBox<T>
or
a direct allocation with the arena through fdf_arena_allocate
, and is:
- initialized to a value of
T
. - properly aligned for
T
. - pointing to the beginning of the object, and not to a subfield of another
ArenaBox
ed object.
Sourcepub fn make_static<T>(&self, data: ArenaBox<'_, T>) -> ArenaStaticBox<T>where
T: ?Sized,
pub fn make_static<T>(&self, data: ArenaBox<'_, T>) -> ArenaStaticBox<T>where
T: ?Sized,
Moves the given ArenaBox
into an ArenaStaticBox
with an owned
reference to this Arena
, allowing for it to be used in 'static
contexts.
§Panics
Panics if the given ArenaBox
is not allocated from this arena.
Sourcepub fn insert_from_iter<I>(
&self,
source: I,
) -> ArenaBox<'_, [<I as IntoIterator>::Item]>
pub fn insert_from_iter<I>( &self, source: I, ) -> ArenaBox<'_, [<I as IntoIterator>::Item]>
Creates an ArenaBox
ed slice from an iterator implementing ExactSizeIterator
. Note
that if ExactSizeIterator::len
returns an incorrect value, the returned ArenaBox
will be no more than the length returned, and may be less.
Sourcepub fn try_insert_from_iter<I, T, E>(
&self,
source: I,
) -> Result<ArenaBox<'_, [T]>, E>
pub fn try_insert_from_iter<I, T, E>( &self, source: I, ) -> Result<ArenaBox<'_, [T]>, E>
Tries to create an ArenaBox
ed slice from an iterator implementing ExactSizeIterator
.
Note that if ExactSizeIterator::len
returns an incorrect value, the returned
ArenaBox
will be no more than the length returned, and may be less.
If any item returned by the iterator returns an Err() result, results so far are discarded
Trait Implementations§
impl Send for Arena
impl Sync for Arena
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)