Trait Encode

Source
pub trait Encode {
    type Error: EncodeError;

    // Required method
    fn try_serialize(self) -> Result<impl Into<Vec<u8>>, Self::Error>;
}
Expand description

A payload which can be converted to a vector of bytes

Required Associated Types§

Source

type Error: EncodeError

The error type returned when encoding fails.

Required Methods§

Source

fn try_serialize(self) -> Result<impl Into<Vec<u8>>, Self::Error>

Convert the payload to a vector of bytes

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Encode for &str

Source§

impl Encode for &[u8]

Source§

impl Encode for Option<Vec<u8>>

Source§

impl Encode for Value

Source§

type Error = Error

Source§

fn try_serialize(self) -> Result<impl Into<Vec<u8>>, Self::Error>

Source§

impl Encode for ()

Source§

impl Encode for String

Source§

impl Encode for Vec<u8>

Implementors§