Module destream::de

source ·
Expand description

Stream deserialization framework with an interface based on serde::de.

The two most important traits in this module are FromStream and Decoder.

  • A type that implements FromStream is a data structure that can be decoded from any stream encoding supported by destream, and conversely
  • A type that implements Decoder is a data format that can decode any supported stream.

The FromStream trait

destream implements FromStream for many Rust primitive and standard library types. The complete list is below.

Implementations of FromStream provided by destream

  • Primitive types:
    • ()
    • bool
    • i8, i16, i32, i64
    • u8, u16, u32, u64, usize
    • f32, f64
  • Compound types:
    • [T; 0] through [T; 32]
    • tuples up to size 16
  • Common standard library types:
    • String
    • Option<T>
    • PhantomData<T>
  • Other common types:
    • Bytes
    • Uuid
  • Collection types:
    • BTreeMap<K, V>
    • BTreeSet<T>
    • BinaryHeap<T>
    • HashMap<K, V, H>
    • HashSet<T, H>
    • LinkedList<T>
    • VecDeque<T>
    • Vec<T>

Enable support for SmallVec using the smallvec feature flag.

Traits

  • Provides a Visitor with access to an array of type T.
  • A data format that can decode a given well-formatted stream using one or more Visitors.
  • The Error trait allows FromStream implementations to create descriptive error messages belonging to their Decoder context.
  • This trait describes a value which can be decoded from a stream.
  • Provides a Visitor with access to each entry of a map in the input.
  • Provides a Visitor access to each element of a sequence in the input.
  • This trait describes a visitor responsible for decoding a stream.