Skip to main content

EncodeExt

Trait EncodeExt 

Source
pub trait EncodeExt: Encode {
    // Provided method
    fn encode_to_vec(&self) -> Result<Vec<u8>, Self::Error> { ... }
}
Expand description

Crate-local conveniences over any codec Encode type.

The codec’s Encode trait provides encode, encoded_size, and encode_to_slice; this extension adds the heap-allocating encode_to_vec helper for std builds. It is blanket-implemented for every Encode type, so bringing it into scope makes encode_to_vec available anywhere.

Provided Methods§

Source

fn encode_to_vec(&self) -> Result<Vec<u8>, Self::Error>

Encode into a newly allocated Vec<u8>.

§Errors

Returns an error if encoding fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Encode> EncodeExt for T