pub(super) struct FrameCodec {
    in_buffer: BytesMut,
    in_buf_max_read: usize,
    out_buffer: Vec<u8>,
    max_out_buffer_len: usize,
    out_buffer_write_len: usize,
    header: Option<(FrameHeader, u64)>,
}Expand description
A codec for WebSocket frames.
Fields§
§in_buffer: BytesMutBuffer to read data from the stream.
in_buf_max_read: usize§out_buffer: Vec<u8>Buffer to send packets to the network.
max_out_buffer_len: usizeCapacity limit for out_buffer.
out_buffer_write_len: usizeBuffer target length to reach before writing to the stream
on calls to buffer_frame.
Setting this to non-zero will buffer small writes from hitting the stream.
header: Option<(FrameHeader, u64)>Header and remaining size of the incoming packet being processed.
Implementations§
Source§impl FrameCodec
 
impl FrameCodec
Sourcepub(super) fn from_partially_read(part: Vec<u8>, min_in_buf_len: usize) -> Self
 
pub(super) fn from_partially_read(part: Vec<u8>, min_in_buf_len: usize) -> Self
Create a new frame codec from partially read data.
Sourcepub(super) fn set_max_out_buffer_len(&mut self, max: usize)
 
pub(super) fn set_max_out_buffer_len(&mut self, max: usize)
Sets a maximum size for the out buffer.
Sourcepub(super) fn set_out_buffer_write_len(&mut self, len: usize)
 
pub(super) fn set_out_buffer_write_len(&mut self, len: usize)
Sets Self::buffer_frame buffer target length to reach before
writing to the stream.
Sourcepub(super) fn read_frame(
    &mut self,
    stream: &mut impl Read,
    max_size: Option<usize>,
    unmask: bool,
    accept_unmasked: bool,
) -> Result<Option<Frame>>
 
pub(super) fn read_frame( &mut self, stream: &mut impl Read, max_size: Option<usize>, unmask: bool, accept_unmasked: bool, ) -> Result<Option<Frame>>
Read a frame from the provided stream.
Sourcefn read_in(&mut self, stream: &mut impl Read) -> Result<usize>
 
fn read_in(&mut self, stream: &mut impl Read) -> Result<usize>
Read into available in_buffer capacity.
Sourcepub(super) fn buffer_frame<Stream>(
    &mut self,
    stream: &mut Stream,
    frame: Frame,
) -> Result<()>where
    Stream: Write,
 
pub(super) fn buffer_frame<Stream>(
    &mut self,
    stream: &mut Stream,
    frame: Frame,
) -> Result<()>where
    Stream: Write,
Writes a frame into the out_buffer.
If the out buffer size is over the out_buffer_write_len will also write
the out buffer into the provided stream.
To ensure buffered frames are written call Self::write_out_buffer.
May write to the stream, will not flush.
Sourcepub(super) fn write_out_buffer<Stream>(
    &mut self,
    stream: &mut Stream,
) -> Result<()>where
    Stream: Write,
 
pub(super) fn write_out_buffer<Stream>(
    &mut self,
    stream: &mut Stream,
) -> Result<()>where
    Stream: Write,
Writes the out_buffer to the provided stream.
Does not flush.