From 962420a4f3561ebcd818f7594879e1d4c870d0a4 Mon Sep 17 00:00:00 2001 From: Minh Vu Date: Mon, 6 Jul 2026 13:44:17 +0200 Subject: [PATCH] codec: document `UdpFramed` decoder errors (#8248) --- tokio-util/src/udp/frame.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tokio-util/src/udp/frame.rs b/tokio-util/src/udp/frame.rs index 84a8096dc..c0719bce3 100644 --- a/tokio-util/src/udp/frame.rs +++ b/tokio-util/src/udp/frame.rs @@ -22,6 +22,12 @@ use std::{ /// handle encoding and decoding of messages frames. Note that the incoming and /// outgoing frame types may be distinct. /// +/// A single datagram may decode into multiple frames. `UdpFramed` will keep +/// calling [`Decoder::decode_eof`] with the current datagram until it returns +/// `Ok(None)`. If a decoder wants to discard a malformed datagram and continue +/// receiving later datagrams, it should consume or clear the remaining bytes +/// from the buffer before returning `Err`. +/// /// This function returns a *single* object that is both [`Stream`] and [`Sink`]; /// grouping this into a single object is often useful for layering things which /// require both read and write access to the underlying object.