Trait ed::Decode[][src]

pub trait Decode: Sized {
    fn decode<R: Read>(input: R) -> Result<Self>;

    fn decode_into<R: Read>(&mut self, input: R) -> Result<()> { ... }
}
Expand description

A trait for values that can be decoded from bytes deterministically.

Required methods

Reads bytes from the reader and returns the decoded value.

When possible, calling decode_into will often be more efficient since it lets the caller reuse memory to avoid allocating for fields with types such as Vec<T>.

Provided methods

Reads bytes from the reader and mutates self to the decoded value.

This is often more efficient than calling decode when reading fields with heap-allocated types such as Vec<T> since it can reuse the memory already allocated in self.

When possible, implementations should recursively call decode_into on any child fields.

The default implementation of decode_into simply calls decode for ease of implementation, but should be overridden when in-place decoding is possible.

Implementations on Foreign Types

Decodes the integer from fixed-size big-endian bytes.

Decodes the integer from fixed-size big-endian bytes.

Decodes the integer from fixed-size big-endian bytes.

Decodes the integer from fixed-size big-endian bytes.

Decodes the integer from fixed-size big-endian bytes.

Decodes the integer from fixed-size big-endian bytes.

Decodes the integer from fixed-size big-endian bytes.

Decodes the integer from fixed-size big-endian bytes.

Decodes the integer from fixed-size big-endian bytes.

Decodes the integer from fixed-size big-endian bytes.

Decodes the boolean from a single byte: 0 for false or 1 for true. Errors for any other value.

Decodes a 0 byte as None, or a 1 byte followed by the encoding of the inner value as Some. Errors for all other values.

Decodes a 0 byte as None, or a 1 byte followed by the encoding of the inner value as Some. Errors for all other values.

Returns a unit tuple without reading any bytes.

Decodes the fields of the tuple one after another, in order.

Decodes the fields of the tuple one after another, in order.

Recursively calls decode_into for each field.

Decodes the fields of the tuple one after another, in order.

Decodes the fields of the tuple one after another, in order.

Recursively calls decode_into for each field.

Decodes the fields of the tuple one after another, in order.

Decodes the fields of the tuple one after another, in order.

Recursively calls decode_into for each field.

Decodes the fields of the tuple one after another, in order.

Decodes the fields of the tuple one after another, in order.

Recursively calls decode_into for each field.

Decodes the fields of the tuple one after another, in order.

Decodes the fields of the tuple one after another, in order.

Recursively calls decode_into for each field.

Decodes the fields of the tuple one after another, in order.

Decodes the fields of the tuple one after another, in order.

Recursively calls decode_into for each field.

Decodes the fields of the tuple one after another, in order.

Decodes the fields of the tuple one after another, in order.

Recursively calls decode_into for each field.

Decodes the elements of the vector one after another, in order.

Encodes the elements of the vector one after another, in order.

Recursively calls decode_into for each element.

Decodes the inner value into a new Box.

Decodes the inner value into the existing Box.

Recursively calls decode_into on the inner value.

Implementors