expression
Bound the declared binary payload
Reject a declared size beyond the configured cap without waiting for that entire payload. This is a per-frame policy, not a global memory budget or connection limit. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): true Common mistake: Allocating a buffer solely from a peer-controlled size field.
Formal Syntax & Structure
rust syntaxrust
LengthDelimitedCodec::builder().max_frame_length(n).new_codec()Working Example
Example Snippetrust
fn main() { use bytes::BytesMut; use tokio_util::codec::{Decoder, LengthDelimitedCodec}; let mut c = LengthDelimitedCodec::builder().max_frame_length(8).new_codec(); let mut b = BytesMut::from(&[0, 0, 0, 9][..]); println!("{}", c.decode(&mut b).is_err());}