Trait FromMidenRepr

Source
pub trait FromMidenRepr: Sized {
    // Required methods
    fn size_in_felts() -> usize;
    fn from_bytes(bytes: &[u8]) -> Self;

    // Provided methods
    fn from_felts(felts: &[RawFelt]) -> Self { ... }
    fn from_words(words: &[Word]) -> Self { ... }
    fn pop_from_stack(stack: &mut Vec<RawFelt>) -> Self { ... }
}

Required Methods§

Source

fn size_in_felts() -> usize

Returns the size of this type as encoded by ToMidenRepr::to_felts

Source

fn from_bytes(bytes: &[u8]) -> Self

Extract a value of this type from bytes, where:

  • It is assumed that bytes is always padded out to 4 byte alignment
  • It is assumed that the bytes are in little-endian order, as encoded by ToMidenRepr

Provided Methods§

Source

fn from_felts(felts: &[RawFelt]) -> Self

Extract a value of this type as encoded in a vector of field elements, where:

  • The order of the field elements is little-endian, i.e. the element holding the least significant bytes comes first.
Source

fn from_words(words: &[Word]) -> Self

Extract a value of this type as encoded in a vector of words, where:

  • The order of the words is little-endian, i.e. the word holding the least significant bytes comes first.
  • The order of the field elements in each word is in big-endian order, i.e. the element with the most significant byte is at the start of the word, and the element with the least significant byte is at the end of the word. This corresponds to the order in which elements are placed on the operand stack when preparing to read or write them from Miden’s memory.
Source

fn pop_from_stack(stack: &mut Vec<RawFelt>) -> Self

Pop a value of this type from stack based on the canonical representation of this type on the operand stack when writing it to memory (and as read from memory).

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

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

fn pop_from_stack(stack: &mut Vec<RawFelt>) -> Self

Source§

impl FromMidenRepr for i8

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

fn pop_from_stack(stack: &mut Vec<RawFelt>) -> Self

Source§

impl FromMidenRepr for i16

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

fn pop_from_stack(stack: &mut Vec<RawFelt>) -> Self

Source§

impl FromMidenRepr for i32

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

fn pop_from_stack(stack: &mut Vec<RawFelt>) -> Self

Source§

impl FromMidenRepr for i64

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

impl FromMidenRepr for i128

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

impl FromMidenRepr for u8

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

fn pop_from_stack(stack: &mut Vec<RawFelt>) -> Self

Source§

impl FromMidenRepr for u16

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

fn pop_from_stack(stack: &mut Vec<RawFelt>) -> Self

Source§

impl FromMidenRepr for u32

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

fn pop_from_stack(stack: &mut Vec<RawFelt>) -> Self

Source§

impl FromMidenRepr for u64

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

impl FromMidenRepr for u128

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

impl FromMidenRepr for Felt

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn from_felts(felts: &[RawFelt]) -> Self

Source§

fn from_words(words: &[Word]) -> Self

Source§

impl<const N: usize> FromMidenRepr for [u8; N]

Source§

fn size_in_felts() -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Implementors§

Source§

impl FromMidenRepr for midenc_debug::Felt