pub struct RawVec { /* private fields */ }Expand description
A vector of bytes aligned to a given value. The alignment can be increase by calling align.
Implementations§
Source§impl RawVec
impl RawVec
Sourcepub fn with_base_alignment(base_alignment: usize) -> Self
pub fn with_base_alignment(base_alignment: usize) -> Self
Creates a new RawVec with base alignment.
§Examples
use cel_runtime::RawVec;
use std::mem::align_of;
let vec = RawVec::with_base_alignment(align_of::<u32>());Sourcepub fn with_base_alignment_and_capacity(
base_alignment: usize,
capacity: usize,
) -> Self
pub fn with_base_alignment_and_capacity( base_alignment: usize, capacity: usize, ) -> Self
Creates a new RawVec with base alignment and initial capacity.
Sourcepub fn reserve(&mut self, addition: usize)
pub fn reserve(&mut self, addition: usize)
Reserves capacity for at least additional more elements. The collection may reserve more
space to guarantee amortized constant time growth. After calling reserve, capacity will be
greater than or equal to self.len() + additional. Does nothing if capacity is already
sufficient.
§Panics
Panics if the new capacity exceeds isize::MAX bytes.
Sourcepub unsafe fn as_mut_ptr(&mut self) -> *mut MaybeUninit<u8>
pub unsafe fn as_mut_ptr(&mut self) -> *mut MaybeUninit<u8>
Returns a raw mutable pointer to the vector’s buffer, or a dangling raw pointer valid for zero sized reads if the vector didn’t allocate.
This method guarantees that for the purpose of the aliasing model, this method does not
materialize a reference to the underlying slice, and thus the returned pointer will remain
valid when mixed with other calls to Self::as_ptr, Self::as_mut_ptr. Note
that calling other methods that materialize references to the slice, or references to
specific elements you are planning on accessing through this pointer, may still invalidate
this pointer.
§Safety
The pointer is valid until the vector buffer is reallocated or the vector’s lifetime ends.
Sourcepub unsafe fn as_ptr(&self) -> *const MaybeUninit<u8>
pub unsafe fn as_ptr(&self) -> *const MaybeUninit<u8>
Returns a raw pointer to the vector’s buffer, or a dangling raw pointer valid for zero sized reads if the vector didn’t allocate.
The caller must also ensure that the memory the pointer (non-transitively) points to is
never written to (except inside an UnsafeCell) using this pointer or any pointer derived
from it. If you need to mutate the contents of the slice, use Self::as_mut_ptr.
This method guarantees that for the purpose of the aliasing model, this method does not
materialize a reference to the underlying slice, and thus the returned pointer will remain
valid when mixed with other calls to Self::as_ptr, Self::as_mut_ptr. Note
that calling other methods that materialize mutable references to the slice, or mutable
references to specific elements you are planning on accessing through this pointer, as well
as writing to those elements, may still invalidate this pointer.
§Safety
The pointer is valid until the vector buffer is reallocated or the vector’s lifetime ends.