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§
Sourceconst MAX_OFFSET: u32 = 268_435_456u32
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§
fn label_friendly_name() -> String
Sourcefn compute_size_and_assert_valid_size_indicator(
library: &mut Library,
) -> Vec<LabelledInstruction>
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
Provided Methods§
fn decode_from_memory( memory: &HashMap<BFieldElement, BFieldElement>, address: BFieldElement, ) -> Result<Box<Self>, Box<dyn Error + Send + Sync>>
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.