expression
Read the next HTTP body frame
A body can yield data or trailing metadata, followed by end of stream. Read one frame at a time; the result distinguishes a frame error from normal completion. Full in this fixture emits one nonempty data frame. In-memory fixture; no external connection. Expected stdout (not executed): 3 true Common mistake: Treating None as a failed read or assuming every frame carries data.
Formal Syntax & Structure
rust syntaxrust
body.frame().await -> Option<Result<Frame<_>, _>>Working Example
Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() { use hyper::body::Bytes; use http_body_util::{Full, BodyExt}; let mut body = Full::new(Bytes::from_static(b"abc")); let data = body.frame().await.unwrap().unwrap().into_data().unwrap(); println!("{}", data.len()); println!("{}", body.frame().await.is_none());}