Struct websocket_base::codec::ws::DataFrameCodec
source · [−]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<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<Self::Item>, Self::Error>
fn decode(
&mut self,
src: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>
Attempts to decode a frame from the provided buffer of bytes. Read more
sourceimpl<D> Encoder for DataFrameCodec<D> where
D: Borrow<dyn DataFrameTrait>,
impl<D> Encoder for DataFrameCodec<D> where
D: Borrow<dyn DataFrameTrait>,
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