Trait AllocBytes

Source
pub trait AllocBytes:
    Clone
    + Debug
    + Deref<Target = [u8]>
    + DerefMut<Target = [u8]> {
    type AllocParams;

    // Required methods
    fn from_bytes<'a>(
        slice: impl Into<Cow<'a, [u8]>>,
        _align: Align,
        _params: Self::AllocParams,
    ) -> Self;
    fn zeroed(
        size: Size,
        _align: Align,
        _params: Self::AllocParams,
    ) -> 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 Associated Types§

Source

type AllocParams

The type of extra parameters passed in when creating an allocation. Can be used by interpret::Machine instances to make runtime-configuration-dependent decisions about the allocation strategy.

Required Methods§

Source

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

Create an AllocBytes from a slice of u8.

Source

fn zeroed(size: Size, _align: Align, _params: Self::AllocParams) -> 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§

type AllocParams = ()

Source§

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

Source§

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

Source§

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

Source§

fn as_ptr(&self) -> *const u8

Implementors§