pub struct FrameBuffer { /* private fields */ }Expand description
Incremental buffer for decoding length-prefixed protocol frames.
Implementations§
Source§impl FrameBuffer
impl FrameBuffer
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Construct an empty frame buffer with a preallocated capacity.
Sourcepub fn try_decode<T>(&mut self) -> Result<Option<T>, ProtocolError>where
T: DeserializeOwned,
pub fn try_decode<T>(&mut self) -> Result<Option<T>, ProtocolError>where
T: DeserializeOwned,
Attempt to decode a single frame from the buffer.
If a complete frame is available, it is decoded and then removed from the internal buffer.
If the buffer does not yet contain a full frame, no data is discarded from the buffer.
§Returns
Ok(None)- if no complete frame available in the buffer,- decoded frame value - if a full frame is present in the buffer and succesfully decoded.
§Errors
Returns ProtocolError if:
- buffer data contains a malformed complete frame,
- frame length is out of range,
- deserialization fails.
Trait Implementations§
Source§impl Clone for FrameBuffer
impl Clone for FrameBuffer
Source§fn clone(&self) -> FrameBuffer
fn clone(&self) -> FrameBuffer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FrameBuffer
impl Debug for FrameBuffer
Source§impl Default for FrameBuffer
impl Default for FrameBuffer
Source§fn default() -> FrameBuffer
fn default() -> FrameBuffer
Returns the “default value” for a type. Read more
Source§impl PartialEq for FrameBuffer
impl PartialEq for FrameBuffer
impl Eq for FrameBuffer
impl StructuralPartialEq for FrameBuffer
Auto Trait Implementations§
impl Freeze for FrameBuffer
impl RefUnwindSafe for FrameBuffer
impl Send for FrameBuffer
impl Sync for FrameBuffer
impl Unpin for FrameBuffer
impl UnsafeUnpin for FrameBuffer
impl UnwindSafe for FrameBuffer
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