expression

Read through a byte delimiter

Collect bytes up to and including a delimiter, or the remaining input at EOF. The delimiter is part of the result; no record-size cap is implicit. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): red| Common mistake: Assuming the delimiter is omitted or that arbitrary input is size-limited.

Formal Syntax & Structure

rust syntaxrust
reader.read_until(delimiter, &mut bytes).await

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() {    use tokio::io::{AsyncBufReadExt, BufReader};    let mut r = BufReader::new(&b"red|blue"[..]);    let mut bytes = Vec::new();    r.read_until(b'|', &mut bytes).await.unwrap();    println!("{}", String::from_utf8(bytes).unwrap());}
Rust Reference