pub struct Codec { /* private fields */ }
Expand description
Codec for encoding/decoding websocket base frames.
Implementations§
source§impl Codec
impl Codec
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new base frame codec.
The codec will support decoding payload lengths up to 256 MiB
(use set_max_data_size
to change this value).
sourcepub fn max_data_size(&self) -> usize
pub fn max_data_size(&self) -> usize
Get the configured maximum payload length.
sourcepub fn set_max_data_size(&mut self, size: usize) -> &mut Self
pub fn set_max_data_size(&mut self, size: usize) -> &mut Self
Limit the maximum size of payload data to size
bytes.
sourcepub fn reserved_bits(&self) -> (bool, bool, bool)
pub fn reserved_bits(&self) -> (bool, bool, bool)
The reserved bits currently configured.
sourcepub fn add_reserved_bits(&mut self, bits: (bool, bool, bool)) -> &mut Self
pub fn add_reserved_bits(&mut self, bits: (bool, bool, bool)) -> &mut Self
Add to the reserved bits in use.
sourcepub fn clear_reserved_bits(&mut self)
pub fn clear_reserved_bits(&mut self)
Reset the reserved bits.
sourcepub fn decode_header(
&self,
bytes: &[u8],
) -> Result<Parsing<Header, usize>, Error>
pub fn decode_header( &self, bytes: &[u8], ) -> Result<Parsing<Header, usize>, Error>
Decode a websocket frame header.
sourcepub fn encode_header(&mut self, header: &Header) -> &[u8] ⓘ
pub fn encode_header(&mut self, header: &Header) -> &[u8] ⓘ
Encode a websocket frame header.
sourcepub fn apply_mask(header: &Header, data: &mut [u8])
pub fn apply_mask(header: &Header, data: &mut [u8])
Use the given header’s mask and apply it to the data.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Codec
impl RefUnwindSafe for Codec
impl Send for Codec
impl Sync for Codec
impl Unpin for Codec
impl UnwindSafe for Codec
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)