Encoder

Trait Encoder 

Source
pub trait Encoder {
    // Required methods
    fn current_chunk(&self) -> &[u8] ;
    fn advance(&mut self) -> bool;
}
Expand description

An encoder for a consensus-encodable object.

Required Methods§

Source

fn current_chunk(&self) -> &[u8]

Yields the current encoded byteslice.

Will always return the same value until Self::advance is called. May return an empty list.

Source

fn advance(&mut self) -> bool

Moves the encoder to its next state.

Does not need to be called when the encoder is first created. (In fact, if it is called, this will discard the first chunk of encoded data.)

§Returns
  • true if the encoder has advanced to a new state and Self::current_chunk will return new data.
  • false if the encoder is exhausted and has no more states.

Implementations on Foreign Types§

Source§

impl<T: Encoder> Encoder for Option<T>

Source§

fn current_chunk(&self) -> &[u8]

Source§

fn advance(&mut self) -> bool

Implementors§

Source§

impl Encoder for BytesEncoder<'_>

Source§

impl Encoder for CompactSizeEncoder

Source§

impl<A: Encoder, B: Encoder> Encoder for Encoder2<A, B>

Source§

impl<A: Encoder, B: Encoder, C: Encoder> Encoder for Encoder3<A, B, C>

Source§

impl<A: Encoder, B: Encoder, C: Encoder, D: Encoder> Encoder for Encoder4<A, B, C, D>

Source§

impl<A: Encoder, B: Encoder, C: Encoder, D: Encoder, E: Encoder, F: Encoder> Encoder for Encoder6<A, B, C, D, E, F>

Source§

impl<T: Encodable> Encoder for SliceEncoder<'_, T>

Source§

impl<const N: usize> Encoder for ArrayEncoder<N>