Skip to main content

FromFeltRepr

Trait FromFeltRepr 

Source
pub trait FromFeltRepr: Sized {
    const FIXED_LEN: Option<usize> = None;

    // Required method
    fn from_felt_repr(
        reader: &mut FeltReader<'_>,
    ) -> Result<Self, FeltReprError>;
}
Expand description

Trait for deserialization from felt memory representation.

Provided Associated Constants§

Source

const FIXED_LEN: Option<usize> = None

Total encoded length in felts, when statically known.

None marks a variable-length encoding: a type containing Vec or Option fields, or an enum whose variants encode to different lengths. When Some(n), n must equal the exact number of felts consumed by Self::from_felt_repr (and produced by the matching ToFeltRepr implementation, if any).

Defaults to None, which is always correct for a manual implementation — consumers that dispatch on the length (e.g. the tx-script args transport) merely fall back to their variable-length path. Override it with the exact count to enable fixed-length dispatch; #[derive(FromFeltRepr)] computes it automatically.

Required Methods§

Source

fn from_felt_repr(reader: &mut FeltReader<'_>) -> Result<Self, FeltReprError>

Deserializes from a FeltReader, consuming the required elements.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromFeltRepr for bool

Source§

impl FromFeltRepr for u8

Source§

impl FromFeltRepr for u32

Source§

impl FromFeltRepr for u64

Source§

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

Encodes an Option<T> as a 1-felt tag followed by the payload (if present).

Format:

  • None => [0]
  • Some(x) => [1, x...]
Source§

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

Encodes a Vec<T> as a length prefix followed by elements.

Format: [len, elem0..., elemN-1...] where len is a u32 encoded in a single Felt.

Implementors§