pub trait Codec: Clone + Sized {
    fn variant_type(&self) -> &'static str;
fn encode<W>(&self, w: &mut W) -> Result<(), Error>
    where
        W: Write
;
fn decode<R>(r: &mut R) -> Result<Self, Error>
    where
        R: Read
; fn encode_vec(&self) -> Result<Vec<u8>, Error> { ... }
fn decode_ref(r: &[u8]) -> Result<(u64, Self), Error> { ... } }
Expand description

Apply to a data item to indicate it can be encoded / decoded.

Required methods

Variant identifier (for debugging or as a cheap discriminant).

Encode this item to given writer. You may wish to first wrap your writer in a BufWriter.

Decode a reader into this item. You may wish to first wrap your reader in a BufReader.

Provided methods

Encode this item to an owned vector of bytes. Uses encode() internally.

Decode a range of bytes into this item. Will also return the byte count read. Uses decode() internally.

Implementors