pub struct OwnedAlignedBuffer { /* private fields */ }
Expand description
Owned aligned buffer for executor purposes.
See SharedAlignedBuffer
for a version that can be cheaply cloned, while reusing the original
allocation.
Data is aligned to 16 bytes (128 bits), which is the largest alignment required by primitive
types and by extension any type that implements TrivialType
/IoType
.
Implementations§
Source§impl OwnedAlignedBuffer
impl OwnedAlignedBuffer
Sourcepub fn with_capacity(capacity: u32) -> Self
pub fn with_capacity(capacity: u32) -> Self
Create a new instance with at least specified capacity.
NOTE: Actual capacity might be larger due to alignment requirements.
Sourcepub fn from_bytes(bytes: &[u8]) -> Self
pub fn from_bytes(bytes: &[u8]) -> Self
pub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_ptr(&self) -> *const u8
pub fn as_mut_ptr(&mut self) -> *mut u8
Sourcepub fn ensure_capacity(&mut self, capacity: u32)
pub fn ensure_capacity(&mut self, capacity: u32)
Ensure capacity of the buffer is at least capacity
.
Will re-allocate if necessary.
Sourcepub fn copy_from_slice(&mut self, bytes: &[u8])
pub fn copy_from_slice(&mut self, bytes: &[u8])
Will re-allocate if capacity is not enough to store provided bytes.
§Panics
If bytes.len()
doesn’t fit into u32
pub fn is_empty(&self) -> bool
pub fn len(&self) -> u32
pub fn capacity(&self) -> u32
Trait Implementations§
Source§impl Clone for OwnedAlignedBuffer
impl Clone for OwnedAlignedBuffer
Auto Trait Implementations§
impl Freeze for OwnedAlignedBuffer
impl RefUnwindSafe for OwnedAlignedBuffer
impl Send for OwnedAlignedBuffer
impl Sync for OwnedAlignedBuffer
impl Unpin for OwnedAlignedBuffer
impl UnwindSafe for OwnedAlignedBuffer
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
Mutably borrows from an owned value. Read more