# tokio_util::codec::length_delimited::LengthDelimitedCodec - Rust
API documentation for the Rust `LengthDelimitedCodec` struct in crate `tokio_util`.
Keywords: rust, rustlang, rust-lang, LengthDelimitedCodec

# Struct tokio_util::codec::length_delimited::LengthDelimitedCodec [−] [src]

    pub struct LengthDelimitedCodec { /* fields omitted */ }

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.

## Implementations

### `impl LengthDelimitedCodec` [src]

#### `pub fn new() -> Self` [src]

Creates a new `LengthDelimitedCodec` with the default configuration values.

#### `pub fn builder() -> Builder` [src]

Creates a new length delimited codec builder with default configuration values.

#### `pub fn max_frame_length(&self) -> usize` [src]

Returns the current max frame setting

This is the largest size this codec will accept from the wire. Larger frames will be rejected.

#### `pub fn set_max_frame_length(&mut self, val: usize)` [src]

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.

## Trait Implementations

### `impl Debug for LengthDelimitedCodec` [src]

#### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` [src]

Formats the value using the given formatter. Read more

### `impl Decoder for LengthDelimitedCodec` [src]

#### `type Item = BytesMut`

The type of decoded frames.

#### `type Error = Error`

The type of unrecoverable frame decoding errors. Read more

#### `fn decode(&mut self, src: &mut BytesMut) -> Result<Option<BytesMut>>` [src]

Attempts to decode a frame from the provided buffer of bytes. Read more

#### `fn decode_eof(
&mut self,
buf: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>` [src]

A default method available to be called when there are no more bytes available to be read from the underlying I/O. Read more

#### `fn framed<T: AsyncRead + AsyncWrite + Sized>(self, io: T) -> Framed<T, Self> where
Self: Sized,` [src]

Provides a `Stream` and `Sink` interface for reading and writing to this `Io` object, using `Decode` and `Encode` to read and write the raw data. Read more

### `impl Default for LengthDelimitedCodec` [src]

#### `fn default() -> Self` [src]

Returns the "default value" for a type. Read more

### `impl Encoder<Bytes> for LengthDelimitedCodec` [src]

#### `type Error = Error`

The type of encoding errors. Read more

#### `fn encode(&mut self, data: Bytes, dst: &mut BytesMut) -> Result<(), Error>` [src]

Encodes a frame into the buffer provided. Read more

## Auto Trait Implementations

### `impl RefUnwindSafe for LengthDelimitedCodec` [src]

### `impl Send for LengthDelimitedCodec` [src]

### `impl Sync for LengthDelimitedCodec` [src]

### `impl Unpin for LengthDelimitedCodec` [src]

### `impl UnwindSafe for LengthDelimitedCodec` [src]

## Blanket Implementations

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `pub fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T` [src]

#### `pub fn from(t: T) -> T` [src]

Performs the conversion.

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `pub fn into(self) -> U` [src]

Performs the conversion.

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>` [src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.