pub trait DataFrame {
// Required methods
fn is_last(&self) -> bool;
fn opcode(&self) -> u8;
fn reserved(&self) -> &[bool; 3];
fn size(&self) -> usize;
fn write_payload(
&self,
socket: &mut dyn Write
) -> Result<(), WebSocketError>;
fn take_payload(self) -> Vec<u8> ⓘ;
// Provided methods
fn frame_size(&self, masked: bool) -> usize { ... }
fn write_to(
&self,
writer: &mut dyn Write,
mask: bool
) -> Result<(), WebSocketError> { ... }
}
Expand description
A generic DataFrame. Every dataframe should be able to provide these methods. (If the payload is not known in advance then rewrite the write_payload method)
Required Methods§
sourcefn write_payload(&self, socket: &mut dyn Write) -> Result<(), WebSocketError>
fn write_payload(&self, socket: &mut dyn Write) -> Result<(), WebSocketError>
Write the payload to a writer
sourcefn take_payload(self) -> Vec<u8> ⓘ
fn take_payload(self) -> Vec<u8> ⓘ
Takes the payload out into a vec
Provided Methods§
sourcefn frame_size(&self, masked: bool) -> usize
fn frame_size(&self, masked: bool) -> usize
Get’s the size of the entire dataframe in bytes, i.e. header and payload.