Struct tokio_util::codec::length_delimited::LengthDelimitedCodec
source · pub struct LengthDelimitedCodec {
builder: Builder,
state: DecodeState,
}
Expand description
A codec for frames delimited by a frame head specifying their lengths.
This allows the consumer to work with entire frames without having to worry about buffering or other framing logic.
See module level documentation for more detail.
Fields§
§builder: Builder
§state: DecodeState
Implementations§
source§impl LengthDelimitedCodec
impl LengthDelimitedCodec
sourcepub fn builder() -> Builder
pub fn builder() -> Builder
Creates a new length delimited codec builder with default configuration values.
sourcepub fn max_frame_length(&self) -> usize
pub fn max_frame_length(&self) -> usize
Returns the current max frame setting
This is the largest size this codec will accept from the wire. Larger frames will be rejected.
sourcepub fn set_max_frame_length(&mut self, val: usize)
pub fn set_max_frame_length(&mut self, val: usize)
Updates the max frame setting.
The change takes effect the next time a frame is decoded. In other
words, if a frame is currently in process of being decoded with a frame
size greater than val
but less than the max frame length in effect
before calling this function, then the frame will be allowed.
fn decode_head(&mut self, src: &mut BytesMut) -> Result<Option<usize>>
fn decode_data(&self, n: usize, src: &mut BytesMut) -> Option<BytesMut>
Trait Implementations§
source§impl Clone for LengthDelimitedCodec
impl Clone for LengthDelimitedCodec
source§fn clone(&self) -> LengthDelimitedCodec
fn clone(&self) -> LengthDelimitedCodec
Returns a copy 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 LengthDelimitedCodec
impl Debug for LengthDelimitedCodec
source§impl Decoder for LengthDelimitedCodec
impl Decoder for LengthDelimitedCodec
source§fn decode(&mut self, src: &mut BytesMut) -> Result<Option<BytesMut>>
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<BytesMut>>
Attempts to decode a frame from the provided buffer of bytes. Read more
source§impl Default for LengthDelimitedCodec
impl Default for LengthDelimitedCodec
Auto Trait Implementations§
impl Freeze for LengthDelimitedCodec
impl RefUnwindSafe for LengthDelimitedCodec
impl Send for LengthDelimitedCodec
impl Sync for LengthDelimitedCodec
impl Unpin for LengthDelimitedCodec
impl UnwindSafe for LengthDelimitedCodec
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)