pub struct FrameCodec { /* private fields */ }Expand description
Frame codec for encoding/decoding messages
Implementations§
Source§impl FrameCodec
impl FrameCodec
Sourcepub fn with_max_size(max_size: u32) -> Self
pub fn with_max_size(max_size: u32) -> Self
Create a frame codec with custom max size
Sourcepub fn has_complete_frame(&self) -> bool
pub fn has_complete_frame(&self) -> bool
Check if there’s enough data for a complete frame
Sourcepub fn buffer_size(&self) -> usize
pub fn buffer_size(&self) -> usize
Get the current buffer size
Sourcepub fn decode(&mut self) -> Result<Option<Bytes>, FrameError>
pub fn decode(&mut self) -> Result<Option<Bytes>, FrameError>
Decode a frame from the internal buffer Returns None if incomplete, Some(bytes) if complete
Sourcepub fn decode_from(
&self,
src: &mut BytesMut,
) -> Result<Option<Bytes>, FrameError>
pub fn decode_from( &self, src: &mut BytesMut, ) -> Result<Option<Bytes>, FrameError>
Decode a frame from the provided buffer Returns None if incomplete, Some(bytes) if complete
Sourcepub fn encode(&self, msg: &[u8], dst: &mut BytesMut) -> Result<(), FrameError>
pub fn encode(&self, msg: &[u8], dst: &mut BytesMut) -> Result<(), FrameError>
Encode a message into a frame
Sourcepub fn encode_to_bytes(&self, msg: &[u8]) -> Result<Bytes, FrameError>
pub fn encode_to_bytes(&self, msg: &[u8]) -> Result<Bytes, FrameError>
Encode a message and return the framed bytes
Trait Implementations§
Source§impl Debug for FrameCodec
impl Debug for FrameCodec
Auto Trait Implementations§
impl Freeze for FrameCodec
impl RefUnwindSafe for FrameCodec
impl Send for FrameCodec
impl Sync for FrameCodec
impl Unpin for FrameCodec
impl UnsafeUnpin 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