expression

FramedRead converts byte input to a stream

Wrap a byte reader to consume decoded records rather than arbitrary byte chunks. Handle each decoding error and define EOF behavior. This fixture uses two finite text records. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): one two Common mistake: Ignoring errors inside the stream’s Result items.

Formal Syntax & Structure

rust syntaxrust
FramedRead::new(reader, codec); StreamExt::next

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() {    use futures_util::StreamExt;    use tokio_util::codec::{FramedRead, LinesCodec};    let mut r = FramedRead::new(&b"one\ntwo\n"[..], LinesCodec::new_with_max_length(16));    while let Some(line) = r.next().await { println!("{}", line.unwrap()); }}
Rust Reference