Trait ToBytes

Source
pub trait ToBytes {
    // Required method
    fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>;
}
Expand description

Trait that supports writing datatypes into a binary data stream.

Datatypes that implements this trait can be serialized into a binary data stream.

Required Methods§

Source

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Writes data into the given target.

Serializes this instance into its binary representation and writes the binary data into target. Returns the number of bytes actually serialized.

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 ToBytes for &str

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for bool

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for char

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for f32

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for f64

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for i8

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for i16

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for i32

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for i64

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for u8

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for u16

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for u32

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for u64

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for ()

Source§

fn to_bytes<PB: PutBytes>(&self, _target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for usize

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl ToBytes for String

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl<T: ToBytes> ToBytes for Option<T>

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl<TB: ToBytes> ToBytes for &[TB]

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl<TB: ToBytes> ToBytes for Vec<TB>

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Source§

impl<TB: ToBytes, const COUNT: usize> ToBytes for [TB; COUNT]

Source§

fn to_bytes<PB: PutBytes>(&self, target: &mut PB) -> Result<usize, Error>

Implementors§