MemoryPointerLength

Enum MemoryPointerLength 

Source
pub enum MemoryPointerLength {
    X32b,
    X64b,
}
Expand description

An enum deciding the amount of bytes required to point to a location in memory. If the extra memory is not needed, using a smaller MemoryPointerLength can be file size optimization.

§Pointing to the max memory index

X32b => [0xFF, 0xFF, 0xFF, 0xFF]
X64b => [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]

Variants§

§

X32b

32 bit memory pointers - (4 bytes).

§

X64b

64 bit memory pointers - (8 bytes).

Implementations§

Source§

impl MemoryPointerLength

Source

pub fn extract(&self, index: usize, pool: &[u8]) -> usize

Extract a usize from the memory pool at the given start index, until this MemoryPointerLength’s span is satisfied.

See Self::get_span(), [Self::to_usize(&[u8])].

Source

pub fn to_usize(&self, input: &[u8]) -> usize

Convert the given input to a usize.

Panics if this length cannot be fit into a usize.

Source

pub fn fit(&self, mem_ptr_index: usize) -> Vec<u8>

Convert a memory pointer index to its little-endian byte representation.

Source

pub fn get_span(&self) -> usize

Get the byte size of this memory size.

X32b => 4 bytes, X64b => 8 bytes.

Source

pub fn get_byte_identifier(&self) -> u8

Get the this memory pointer length’s byte identifier. This will be placed into the bytecode header.

See [options::header_format_doc] for a full guide regarding the ivm bytecode format.

Source

pub fn from_byte_identifier(byte: u8) -> Option<Self>

Match the memory pointer length from the given byte.

See MemoryPointerLength::get_byte_identifier().

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.