Skip to main content

TreeDecode

Trait TreeDecode 

Source
pub trait TreeDecode<'b, C>: Sized {
    type Builder;

    // Required methods
    fn begin(
        d: &mut Decoder<'b>,
        ctx: &mut C,
    ) -> Result<(Self::Builder, Arity), Error>;
    fn child(builder: &mut Self::Builder, child: Self) -> Result<(), Error>;
    fn end(
        builder: Self::Builder,
        d: &mut Decoder<'b>,
        ctx: &mut C,
    ) -> Result<Self, Error>;
}
Expand description

A recursive type whose nodes can be decoded without recursion.

The driver never reserves memory from a CBOR length header; builders grow only as children are actually decoded from the input.

Required Associated Types§

Source

type Builder

Partially decoded node, accumulating children until end.

Required Methods§

Source

fn begin( d: &mut Decoder<'b>, ctx: &mut C, ) -> Result<(Self::Builder, Arity), Error>

Decode a node’s header: everything up to and including the header of its child list.

Source

fn child(builder: &mut Self::Builder, child: Self) -> Result<(), Error>

Attach the next fully decoded child. Map-like nodes receive keys and values alternately.

Source

fn end( builder: Self::Builder, d: &mut Decoder<'b>, ctx: &mut C, ) -> Result<Self, Error>

Decode anything that follows the child list and finish the node.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§