pub struct FrameCodec { /* private fields */ }Expand description
Frame codec for encoding/decoding frames over async streams
Implementations§
Source§impl FrameCodec
impl FrameCodec
Sourcepub fn with_max_frame_size(max_frame_size: usize) -> Self
pub fn with_max_frame_size(max_frame_size: usize) -> Self
Create a new frame codec with custom max frame size
Sourcepub fn encode_frame(&self, frame: &Frame) -> Result<Bytes, ProtocolError>
pub fn encode_frame(&self, frame: &Frame) -> Result<Bytes, ProtocolError>
Encode a frame to bytes with length prefix
Sourcepub async fn write_frame<W>(
&self,
writer: &mut W,
frame: &Frame,
) -> Result<(), ProtocolError>where
W: AsyncWrite + Unpin,
pub async fn write_frame<W>(
&self,
writer: &mut W,
frame: &Frame,
) -> Result<(), ProtocolError>where
W: AsyncWrite + Unpin,
Write a frame to an async writer
Sourcepub async fn read_frame<R>(
&mut self,
reader: &mut R,
) -> Result<Option<Frame>, ProtocolError>
pub async fn read_frame<R>( &mut self, reader: &mut R, ) -> Result<Option<Frame>, ProtocolError>
Read a frame from an async reader
Sourcepub fn try_decode_frame(&mut self) -> Result<Option<Frame>, ProtocolError>
pub fn try_decode_frame(&mut self) -> Result<Option<Frame>, ProtocolError>
Try to decode a frame from the internal buffer
Sourcepub fn buffer_size(&self) -> usize
pub fn buffer_size(&self) -> usize
Get the current buffer size
Sourcepub fn clear_buffer(&mut self)
pub fn clear_buffer(&mut self)
Clear the internal buffer
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FrameCodec
impl RefUnwindSafe for FrameCodec
impl Send for FrameCodec
impl Sync for FrameCodec
impl Unpin for FrameCodec
impl UnwindSafe for FrameCodec
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