twenty_first::math::bfield_codec

Trait BFieldCodec

Source
pub trait BFieldCodec {
    type Error: Into<Box<dyn Error + Send + Sync>> + Debug + Display;

    // Required methods
    fn decode(sequence: &[BFieldElement]) -> Result<Box<Self>, Self::Error>;
    fn encode(&self) -> Vec<BFieldElement>;
    fn static_length() -> Option<usize>;
}
Expand description

This trait provides functions for encoding to and decoding from a Vec of BFieldElements. This encoding does not record the size of objects nor their type information; this is the responsibility of the decoder.

Required Associated Types§

Required Methods§

Source

fn decode(sequence: &[BFieldElement]) -> Result<Box<Self>, Self::Error>

Source

fn encode(&self) -> Vec<BFieldElement>

Source

fn static_length() -> Option<usize>

Returns the length in number of BFieldElements if it is known at compile-time. Otherwise, None.

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

Source§

impl BFieldCodec for u8

Source§

impl BFieldCodec for u16

Source§

impl BFieldCodec for u32

Source§

impl BFieldCodec for u64

Source§

impl BFieldCodec for u128

Source§

impl<T> BFieldCodec for PhantomData<T>

Source§

impl<T: BFieldCodec> BFieldCodec for Option<T>

Source§

impl<T: BFieldCodec> BFieldCodec for Box<T>

Source§

impl<T: BFieldCodec> BFieldCodec for Vec<T>

Source§

impl<T: BFieldCodec, S: BFieldCodec> BFieldCodec for (T, S)

Source§

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

Implementors§