[−][src]Trait ed::Encode
A trait for values that can be encoded into bytes deterministically.
Required methods
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
Writes the encoded representation of the value to the destination
writer. Can error due to either a write error from dest
, or an
encoding error for types where invalid values are possible.
It may be more convenient to call encode
which
returns bytes, however encode_into
will often be more efficient since
it can write the encoding without necessarily allocating a new
Vec<u8>
.
fn encoding_length(&self) -> Result<usize>
Calculates the length of the encoding for this value. Can error for types where invalid values are possible.
Provided methods
fn encode(&self) -> Result<Vec<u8>>
Returns the encoded representation of the value as a Vec<u8>
.
While this method is convenient, it will often be more efficient to call
encode_into
since encode
usually involves
allocating a new Vec<u8>
.
Implementations on Foreign Types
impl Encode for u8
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the integer as fixed-size big-endian bytes.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the size of the integer in bytes. Will always
return an Ok
result.
impl Encode for u16
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the integer as fixed-size big-endian bytes.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the size of the integer in bytes. Will always
return an Ok
result.
impl Encode for u32
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the integer as fixed-size big-endian bytes.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the size of the integer in bytes. Will always
return an Ok
result.
impl Encode for u64
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the integer as fixed-size big-endian bytes.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the size of the integer in bytes. Will always
return an Ok
result.
impl Encode for u128
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the integer as fixed-size big-endian bytes.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the size of the integer in bytes. Will always
return an Ok
result.
impl Encode for i8
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the integer as fixed-size big-endian bytes.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the size of the integer in bytes. Will always
return an Ok
result.
impl Encode for i16
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the integer as fixed-size big-endian bytes.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the size of the integer in bytes. Will always
return an Ok
result.
impl Encode for i32
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the integer as fixed-size big-endian bytes.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the size of the integer in bytes. Will always
return an Ok
result.
impl Encode for i64
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the integer as fixed-size big-endian bytes.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the size of the integer in bytes. Will always
return an Ok
result.
impl Encode for i128
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the integer as fixed-size big-endian bytes.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the size of the integer in bytes. Will always
return an Ok
result.
impl Encode for bool
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the boolean as a single byte: 0 for false or 1 for true.
fn encoding_length(&self) -> Result<usize>
[src]
Always returns Ok(1).
impl<T: Encode> Encode for Option<T>
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes as a 0 byte for None
, or as a 1 byte followed by the encoding of
the inner value for Some
.
fn encoding_length(&self) -> Result<usize>
[src]
Length will be 1 for None
, or 1 plus the encoding length of the inner
value for Some
.
impl Encode for ()
[src]
fn encode_into<W: Write>(&self, _: &mut W) -> Result<()>
[src]
Encoding a unit tuple is a no-op.
fn encoding_length(&self) -> Result<usize>
[src]
Always returns Ok(0).
impl<A: Encode> Encode for (A,)
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the fields of the tuple one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of the fields of the tuple.
impl<A: Encode + Terminated, B: Encode> Encode for (A, B)
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the fields of the tuple one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of the fields of the tuple.
impl<A: Encode + Terminated, B: Encode + Terminated, C: Encode> Encode for (A, B, C)
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the fields of the tuple one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of the fields of the tuple.
impl<A: Encode + Terminated, B: Encode + Terminated, C: Encode + Terminated, D: Encode> Encode for (A, B, C, D)
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the fields of the tuple one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of the fields of the tuple.
impl<A: Encode + Terminated, B: Encode + Terminated, C: Encode + Terminated, D: Encode + Terminated, E: Encode> Encode for (A, B, C, D, E)
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the fields of the tuple one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of the fields of the tuple.
impl<A: Encode + Terminated, B: Encode + Terminated, C: Encode + Terminated, D: Encode + Terminated, E: Encode + Terminated, F: Encode> Encode for (A, B, C, D, E, F)
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the fields of the tuple one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of the fields of the tuple.
impl<A: Encode + Terminated, B: Encode + Terminated, C: Encode + Terminated, D: Encode + Terminated, E: Encode + Terminated, F: Encode + Terminated, G: Encode> Encode for (A, B, C, D, E, F, G)
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the fields of the tuple one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of the fields of the tuple.
impl<T: Encode + Terminated> Encode for [T; 0]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 1]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 2]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 3]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 4]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 5]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 6]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 7]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 8]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 9]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 10]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 11]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 12]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 13]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 14]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 15]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 16]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 17]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 18]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 19]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 20]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 21]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 22]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 23]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 24]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 25]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 26]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 27]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 28]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 29]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 30]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 31]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 32]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 33]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 64]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 128]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T; 256]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the array one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for Vec<T>
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the vector one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode + Terminated> Encode for [T]
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the elements of the slice one after another, in order.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the sum of the encoding lengths of all elements.
impl<T: Encode> Encode for Box<T>
[src]
fn encode_into<W: Write>(&self, dest: &mut W) -> Result<()>
[src]
Encodes the inner value.
fn encoding_length(&self) -> Result<usize>
[src]
Returns the encoding length of the inner value.