1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00

document new body map types

This commit is contained in:
Rob Ede
2022-01-23 23:26:35 +00:00
parent 008753f07a
commit 50894e392e
8 changed files with 29 additions and 26 deletions

View File

@ -152,7 +152,6 @@ pub(crate) trait MessageType: Sized {
let k = key.as_str().as_bytes();
let k_len = k.len();
// TODO: drain?
for val in value.iter() {
let v = val.as_ref();
let v_len = v.len();

View File

@ -6,6 +6,7 @@ use std::{
use bytes::Bytes;
use futures_core::Stream;
use pin_project_lite::pin_project;
use crate::error::PayloadError;
@ -15,7 +16,7 @@ pub type BoxedPayloadStream = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadErr
#[deprecated(since = "4.0.0", note = "Renamed to `BoxedPayloadStream`.")]
pub type PayloadStream = BoxedPayloadStream;
pin_project_lite::pin_project! {
pin_project! {
/// A streaming payload.
#[project = PayloadProj]
pub enum Payload<S = BoxedPayloadStream> {

View File

@ -185,7 +185,7 @@ impl<B> Response<B> {
self.replace_body(())
}
/// Map the current body type to another using a closure. Returns a new response.
/// Map the current body type to another using a closure, returning a new response.
///
/// Closure receives the response head and the current body type.
#[inline]
@ -202,6 +202,7 @@ impl<B> Response<B> {
}
}
/// Map the current body to a type-erased `BoxBody`.
#[inline]
pub fn map_into_boxed_body(self) -> Response<BoxBody>
where
@ -210,7 +211,7 @@ impl<B> Response<B> {
self.map_body(|_, body| body.boxed())
}
/// Returns body, consuming this response.
/// Returns the response body, dropping all other parts.
#[inline]
pub fn into_body(self) -> B {
self.body