Trait rustc_middle::mir::interpret::AllocBytes

source ·
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§

source

fn from_bytes<'a>(slice: impl Into<Cow<'a, [u8]>>, _align: Align) -> Self

Create an AllocBytes from a slice of u8.

source

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.

source

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.
source

fn as_ptr(&self) -> *const 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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl AllocBytes for Box<[u8]>

Default bytes for Allocation is a Box<u8>.

source§

fn from_bytes<'a>(slice: impl Into<Cow<'a, [u8]>>, _align: Align) -> Self

source§

fn zeroed(size: Size, _align: Align) -> Option<Self>

source§

fn as_mut_ptr(&mut self) -> *mut u8

source§

fn as_ptr(&self) -> *const u8

Implementors§