pub struct DataFrameCodec<D> { /* private fields */ }
Expand description
A codec for decoding 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.
Implementations
sourceimpl DataFrameCodec<DataFrame>
impl DataFrameCodec<DataFrame>
sourcepub fn default(context: Context) -> DataFrameCodec<DataFrame>
pub fn default(context: Context) -> DataFrameCodec<DataFrame>
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.
sourceimpl<D> DataFrameCodec<D>
impl<D> DataFrameCodec<D>
sourcepub fn new(context: Context) -> DataFrameCodec<D>
pub fn new(context: Context) -> DataFrameCodec<D>
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.
There is a default dataframe size limit imposed. Use new_with_limits
to override it
pub fn new_with_limits(
context: Context,
max_dataframe_size: usize
) -> DataFrameCodec<D>
Trait Implementations
sourceimpl<D> Decoder for DataFrameCodec<D>
impl<D> Decoder for DataFrameCodec<D>
type Error = WebSocketError
type Error = WebSocketError
The type of unrecoverable frame decoding errors. Read more
sourcefn decode(
&mut self,
src: &mut BytesMut
) -> Result<Option<<DataFrameCodec<D> as Decoder>::Item>, <DataFrameCodec<D> as Decoder>::Error>
fn decode(
&mut self,
src: &mut BytesMut
) -> Result<Option<<DataFrameCodec<D> as Decoder>::Item>, <DataFrameCodec<D> as Decoder>::Error>
Attempts to decode a frame from the provided buffer of bytes. Read more
sourceimpl<D> Encoder for DataFrameCodec<D> where
D: Borrow<dyn DataFrame + 'static>,
impl<D> Encoder for DataFrameCodec<D> where
D: Borrow<dyn DataFrame + 'static>,
type Item = D
type Item = D
The type of items consumed by the Encoder
type Error = WebSocketError
type Error = WebSocketError
The type of encoding errors. Read more
Auto Trait Implementations
impl<D> RefUnwindSafe for DataFrameCodec<D> where
D: RefUnwindSafe,
impl<D> Send for DataFrameCodec<D> where
D: Send,
impl<D> Sync for DataFrameCodec<D> where
D: Sync,
impl<D> Unpin for DataFrameCodec<D> where
D: Unpin,
impl<D> UnwindSafe for DataFrameCodec<D> where
D: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more