Trait SerialCtx

Source
pub trait SerialCtx {
    // Required method
    fn serial_ctx<W>(
        &self,
        size_length: SizeLength,
        out: &mut W,
    ) -> Result<(), <W as Write>::Err>
       where W: Write;
}
Expand description

The SerialCtx trait provides a means of writing structures into byte-sinks (Write) using contextual information. The contextual information is:

  • size_length: The number of bytes used to record the length of the data.

Required Methods§

Source

fn serial_ctx<W>( &self, size_length: SizeLength, out: &mut W, ) -> Result<(), <W as Write>::Err>
where W: Write,

Attempt to write the structure into the provided writer, failing if if the length cannot be represented in the provided size_length or only part of the structure could be written.

NB: We use Result instead of Option for better composability with other constructs.

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 SerialCtx for &str

Source§

fn serial_ctx<W>( &self, size_len: SizeLength, out: &mut W, ) -> Result<(), <W as Write>::Err>
where W: Write,

Source§

impl<K> SerialCtx for HashSet<K, BuildHasherDefault<FnvHasher>>
where K: Serial,

Serialization for HashSet given a size_len. Values are not serialized in any particular order.

Source§

fn serial_ctx<W>( &self, size_len: SizeLength, out: &mut W, ) -> Result<(), <W as Write>::Err>
where W: Write,

Source§

impl<K, V> SerialCtx for HashMap<K, V, BuildHasherDefault<FnvHasher>>
where K: Serial, V: Serial,

Serialization for HashMap given a size_len. Keys are not serialized in any particular order.

Source§

fn serial_ctx<W>( &self, size_len: SizeLength, out: &mut W, ) -> Result<(), <W as Write>::Err>
where W: Write,

Source§

impl<T> SerialCtx for &[T]
where T: Serial,

Source§

fn serial_ctx<W>( &self, size_len: SizeLength, out: &mut W, ) -> Result<(), <W as Write>::Err>
where W: Write,

Implementors§

Source§

impl SerialCtx for String

Source§

impl<K> SerialCtx for BTreeSet<K>
where K: Serial + Ord,

Source§

impl<K, V> SerialCtx for BTreeMap<K, V>
where K: Serial + Ord, V: Serial,

Source§

impl<T> SerialCtx for Vec<T>
where T: Serial,