Trait TasmObject

Source
pub trait TasmObject: BFieldCodec {
    const MAX_OFFSET: u32 = 268_435_456u32;

    // Required methods
    fn label_friendly_name() -> String;
    fn compute_size_and_assert_valid_size_indicator(
        library: &mut Library,
    ) -> Vec<LabelledInstruction>;
    fn decode_iter<Itr: Iterator<Item = BFieldElement>>(
        iterator: &mut Itr,
    ) -> Result<Box<Self>, Box<dyn Error + Send + Sync>>;

    // Provided method
    fn decode_from_memory(
        memory: &HashMap<BFieldElement, BFieldElement>,
        address: BFieldElement,
    ) -> Result<Box<Self>, Box<dyn Error + Send + Sync>> { ... }
}
Expand description

This trait defines methods for dealing with primitive types and custom-defined struct types from within the VM, assuming they live in memory as they are encoded with BFieldCodec.

§Dyn-Compatibility

This trait is not dyn-compatible (previously known as “object safe”).

Provided Associated Constants§

Source

const MAX_OFFSET: u32 = 268_435_456u32

Maximum jump distance for encoded size and length indicators. The field getters will compare any length or size indicator read from memory against this value and crash the VM if the indicator is larger or equal.

Required Methods§

Source

fn label_friendly_name() -> String

Source

fn compute_size_and_assert_valid_size_indicator( library: &mut Library, ) -> Vec<LabelledInstruction>

Return the size of self and crash if any contained size-indicator is not valid.

BEFORE: _ *object
AFTER:  _ calculated_size
Source

fn decode_iter<Itr: Iterator<Item = BFieldElement>>( iterator: &mut Itr, ) -> Result<Box<Self>, Box<dyn Error + Send + Sync>>

Decode as Self.

Provided Methods§

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 TasmObject for bool

Source§

impl TasmObject for u32

Source§

impl TasmObject for u64

Source§

impl TasmObject for u128

Source§

impl TasmObject for Claim

Source§

impl TasmObject for Proof

Source§

impl TasmObject for FriResponse

Source§

impl TasmObject for BFieldElement

Source§

impl TasmObject for Polynomial<'static, XFieldElement>

Source§

impl TasmObject for XFieldElement

Source§

impl TasmObject for MmrAccumulator

Source§

impl TasmObject for MmrMembershipProof

Source§

impl TasmObject for MmrSuccessorProof

Source§

impl<T> TasmObject for Option<T>
where T: TasmObject,

Source§

impl<T> TasmObject for Vec<T>
where T: TasmObject,

Source§

impl<T, S> TasmObject for (T, S)
where T: TasmObject, S: TasmObject,

Source§

impl<const N: usize, T> TasmObject for [T; N]
where T: TasmObject,

Implementors§