rustc_middle::mir::interpret

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

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]>

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§