pub trait AllocBytes:
Clone
+ Debug
+ Deref<Target = [u8]>
+ DerefMut<Target = [u8]> {
// Required methods
fn from_bytes<'a>(slice: impl Into<Cow<'a, [u8]>>, _align: Align) -> Self;
fn zeroed(size: Size, _align: Align) -> Option<Self>;
fn as_mut_ptr(&mut self) -> *mut u8;
fn as_ptr(&self) -> *const u8;
}
Expand description
Functionality required for the bytes of an Allocation
.
Required Methods§
sourcefn from_bytes<'a>(slice: impl Into<Cow<'a, [u8]>>, _align: Align) -> Self
fn from_bytes<'a>(slice: impl Into<Cow<'a, [u8]>>, _align: Align) -> Self
Create an AllocBytes
from a slice of u8
.
sourcefn zeroed(size: Size, _align: Align) -> Option<Self>
fn zeroed(size: Size, _align: Align) -> Option<Self>
Create a zeroed AllocBytes
of the specified size and alignment.
Returns None
if we ran out of memory on the host.
sourcefn as_mut_ptr(&mut self) -> *mut u8
fn as_mut_ptr(&mut self) -> *mut u8
Gives direct access to the raw underlying storage.
Crucially this pointer is compatible with:
- other pointers returned by this method, and
- references returned from
deref()
, as long as there was no write.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
source§impl AllocBytes for Box<[u8]>
impl AllocBytes for Box<[u8]>
Default bytes
for Allocation
is a Box<u8>
.