Trait Frame

Source
pub trait Frame: Sync + Send {
    // Required methods
    fn to_bytes(&self) -> Vec<u8> ;
    fn payload(&self) -> Vec<u8> ;
    fn len_as_vec(&self) -> usize;
    fn as_mut_raw_erased(&self) -> *mut ();
}
Expand description

The Frame trait allows for type construction/destruction to/from a chunk of bytes.

Required Methods§

Source

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

Transforms this type into a Vec<u8> in order to send through a stream.

Source

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

Returns the paylaod data section of this Frame

Source

fn len_as_vec(&self) -> usize

Returns the total length of the frame as if to_bytes().len() was called.

Source

fn as_mut_raw_erased(&self) -> *mut ()

Returns a *mut () to the underlying frame in order to cast to/from a specific type from the Trait Object returned from stream reads.

It is up to the caller of this method to take care of the cleanup required of the specific type the pointer was cast to (E.g. by calling `Box::from_raw(ptr)’).

Implementors§