AddressSpaceHostLayout

Trait AddressSpaceHostLayout 

Source
pub trait AddressSpaceHostLayout {
    // Required methods
    fn size(&self) -> usize;
    unsafe fn to_field<F: Field>(&self, value: &[u8]) -> F;
}
Expand description

Each address space in guest memory may be configured with a different type T to represent a memory cell in the address space. On host, the address space will be mapped to linear host memory in bytes. The type T must be plain old data (POD) and be safely transmutable from a fixed size array of bytes. Moreover, each type T must be convertible to a field element F.

We currently implement this trait on the enum MemoryCellType, which includes all cell types that we expect to be used in the VM context.

Required Methods§

Source

fn size(&self) -> usize

Size in bytes of the memory cell type.

Source

unsafe fn to_field<F: Field>(&self, value: &[u8]) -> F

§Safety
  • This function must only be called when value is guaranteed to be of size self.size().
  • Alignment of value must be a multiple of the alignment of F.
  • The field type F must be plain old data.

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.

Implementors§