Trait Decode Copy item path Source pub trait Decode: Sized {
// Required method
fn decode <R: Read >(input: R) -> Result <Self>;
// Provided method
fn decode_into <R: Read >(&mut self, input: R) -> Result <() > { ... }
}Expand description A trait for values that can be decoded from bytes deterministically.
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>.
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.
This trait is not dyn compatible .
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Decodes the boolean from a single byte: 0 for false or 1 for true.
Errors for any other value.
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.
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 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.
Returns a PhantomData without reading any bytes.
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 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.
Decodes the inner value into a new Box.
Decodes the inner value into the existing Box.
Recursively calls decode_into on the inner value.