Skip to main content

ToBytes

Trait ToBytes 

Source
pub trait ToBytes {
    // Required method
    fn to_bytes(&self) -> &[u8] ;
}
Expand description

A cheap conversion from typed data to a byte slice.

Given some data, returns the byte representation of that data. No copy of the data should be performed.

See also the FromBytes trait.

Required Methods§

Source

fn to_bytes(&self) -> &[u8]

Converts the provided data to bytes.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ToBytes for ()

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for String

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for Vec<u8>

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 0]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 1]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 2]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 3]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 4]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 5]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 6]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 7]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 8]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 9]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 10]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 11]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 12]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 13]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 14]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 15]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 16]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 17]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 18]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 19]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 20]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 21]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 22]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 23]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 24]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 25]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 26]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 27]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 28]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 29]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 30]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 31]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8; 32]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for [u8]

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl ToBytes for str

Source§

fn to_bytes(&self) -> &[u8]

Source§

impl<'a, T: ToBytes> ToBytes for &'a T

Source§

fn to_bytes(&self) -> &[u8]

Implementors§