docs(body): fill in documentation of the to_bytes function

This commit is contained in:
Sean McArthur
2019-12-12 15:26:54 -08:00
parent cb71d2cdbd
commit 703ac340cb
2 changed files with 8 additions and 3 deletions

View File

@@ -16,9 +16,10 @@ use crate::upgrade::OnUpgrade;
type BodySender = mpsc::Sender<Result<Bytes, crate::Error>>; type BodySender = mpsc::Sender<Result<Bytes, crate::Error>>;
/// A stream of `Bytes`s, used when receiving bodies. /// A stream of `Bytes`, used when receiving bodies.
/// ///
/// A good default `Payload` to use in many applications. /// A good default [`HttpBody`](crates::body::HttpBody) to use in many
/// applications.
#[must_use = "streams do nothing unless polled"] #[must_use = "streams do nothing unless polled"]
pub struct Body { pub struct Body {
kind: Kind, kind: Kind,

View File

@@ -2,7 +2,11 @@ use bytes::{Buf, BufMut, Bytes};
use super::HttpBody; use super::HttpBody;
/// dox /// Concatenate the buffers from a body into a single `Bytes` asynchronously.
///
/// This may require copying the data into a single buffer. If you don't need
/// a contiguous buffer, prefer the [`aggregate`](crate::body::aggregate)
/// function.
pub async fn to_bytes<T>(body: T) -> Result<Bytes, T::Error> pub async fn to_bytes<T>(body: T) -> Result<Bytes, T::Error>
where where
T: HttpBody, T: HttpBody,