Trait AsBytes

Source
pub trait AsBytes {
    // Required method
    fn as_bytes(&self) -> Vec<u8> ;
}
Expand description

Used to convert struct to raw bytes to be sent over the network

Example:

// We have some struct S that implements this trait
let s = S::new();
// This prints the raw bytes as debug output
dbg!("{}", s.as_bytes());

Required Methods§

Source

fn as_bytes(&self) -> Vec<u8>

Return a Vec<u8> of the same information stored in struct

This is ideal to convert typed values into raw bytes to be sent over the network.

Implementors§