Struct websocket::codec::ws::DataFrameCodec
[−]
[src]
pub struct DataFrameCodec<D> { /* fields omitted */ }
A codec for deconding and encoding websocket dataframes.
This codec decodes dataframes into the crates default implementation
of Dataframe
but can encode and send any struct that implements the
ws::Dataframe
trait. The type of struct to encode is given by the D
type parameter in the struct.
Using dataframes directly is meant for users who want low-level access to the
connection. If you don't want to do anything low-level please use the
MessageCodec
codec instead, or better yet use the ClientBuilder
to make
clients and the Server
to make servers.
Methods
impl DataFrameCodec<DataFrame>
[src]
pub fn default(context: Context) -> Self
[src]
Create a new DataFrameCodec
struct using the crate's implementation
of dataframes for reading and writing dataframes.
Use this method if you don't want to provide a custom implementation for your dataframes.
impl<D> DataFrameCodec<D>
[src]
pub fn new(context: Context) -> DataFrameCodec<D>
[src]
Create a new DataFrameCodec
struct using any implementation of
ws::Dataframe
you want. This is useful if you want to manipulate
the websocket layer very specifically.
If you only want to be able to send and receive the crate's
DataFrame
struct use .default(Context)
instead.
Trait Implementations
impl<D> Decoder for DataFrameCodec<D>
[src]
type Item = DataFrame
The type of decoded frames.
type Error = WebSocketError
The type of unrecoverable frame decoding errors. Read more
fn decode(
&mut self,
src: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>
[src]
&mut self,
src: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>
Attempts to decode a frame from the provided buffer of bytes. Read more
fn decode_eof(
&mut self,
buf: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>
[src]
&mut self,
buf: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>
A default method available to be called when there are no more bytes available to be read from the underlying I/O. Read more
impl<D> Encoder for DataFrameCodec<D> where
D: Borrow<DataFrameTrait>,
[src]
D: Borrow<DataFrameTrait>,