Lines Matching refs:body
23 //! extracted from the message framing. For example, an `HTTP/1.1` message body
34 //! This module provides following body types:
36 //! - [`EmptyBody`]: `EmptyBody` represents an empty body.
37 //! - [`TextBody`]: `TextBody` represents a plain-text body.
65 /// The `sync_impl::Body` trait allows for reading body data synchronously.
72 /// use ylong_http::body::sync_impl::Body;
73 /// use ylong_http::body::TextBody;
76 /// let mut body = TextBody::from_bytes(b"Hello");
83 /// let read = body.data(&mut buf).unwrap();
89 /// let read = body.data(&mut buf).unwrap();
94 /// let read = body.data(&mut buf).unwrap();
100 /// Errors that may occur when reading body data.
103 /// Synchronously reads part of the body data, returning how many bytes
110 /// body has been completely read.
113 /// A part of this body has been read, but the body may not be fully
117 /// An error occurred while reading body data.
129 /// use ylong_http::body::sync_impl::Body;
130 /// use ylong_http::body::TextBody;
133 /// let mut body = TextBody::from_bytes(b"Hello");
140 /// let read = body.data(&mut buf).unwrap();
146 /// let read = body.data(&mut buf).unwrap();
151 /// let read = body.data(&mut buf).unwrap();
183 /// The `async_impl::Body` trait allows for reading body data
191 /// use ylong_http::body::async_impl::Body;
192 /// use ylong_http::body::TextBody;
196 /// let mut body = TextBody::from_bytes(b"Hello");
203 /// let read = body.data(&mut buf).await.unwrap();
209 /// let read = body.data(&mut buf).await.unwrap();
214 /// let read = body.data(&mut buf).await.unwrap();
221 /// Errors that may occur when reading body data.
224 /// Reads part of the body data, returning how many bytes were read.
233 /// Returns a future that reads part of the body data, returning how
240 /// If the length of the `buf` is not 0, it means that this body has
244 /// A part of this body has been read, but the body may not be
249 /// An error occurred while reading body data.
261 /// use ylong_http::body::async_impl::Body;
262 /// use ylong_http::body::TextBody;
266 /// let mut body = TextBody::from_bytes(b"Hello");
273 /// let read = body.data(&mut buf).await.unwrap();
279 /// let read = body.data(&mut buf).await.unwrap();
284 /// let read = body.data(&mut buf).await.unwrap();
295 DataFuture { body: self, buf }
324 /// use ylong_http::body::async_impl::Body;
325 /// use ylong_http::body::ChunkBody;
328 /// // Chunk body contain trailer data
340 /// // read chunk body and return headers
352 TrailerFuture { body: self }
364 body: &'a mut T,
374 Pin::new(&mut *fut.body).poll_trailer(cx)
378 /// A future that reads part of the body data, returning how many bytes
388 body: &'a mut T,
400 Pin::new(&mut *fut.body).poll_data(cx, fut.buf)
404 /// The reuse trait of request body.
406 /// Reset body state, Ensure that the body can be re-read.
439 // Type definitions of the origin of the body data.
446 /// A type that represents the body data is from memory.
471 /// A type that represents the body data is from a synchronous reader.
496 /// A type that represent the body data is from an asynchronous reader.
521 /// A type that represents the body data is from an asynchronous body.
523 pub(crate) body: T,
527 pub(crate) fn new(body: T) -> Self {
528 Self { body }
536 &self.body
542 &mut self.body
549 use crate::body::EmptyBody;
559 use crate::body::sync_impl::Body;
561 let mut body = EmptyBody::new();
562 let body_mut = &mut body;
585 use crate::body::async_impl::Body;
587 let mut body = EmptyBody::new();
588 let body_mut = &mut body;