mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-23 16:21:06 +01:00
remove hidden anybody
This commit is contained in:
parent
84ea9e7e88
commit
5c53db1e4d
46
src/dev.rs
46
src/dev.rs
@ -102,49 +102,3 @@ impl<B> BodyEncoding for crate::HttpResponse<B> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove this if it doesn't appear to be needed
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum AnyBody {
|
||||
None,
|
||||
Full { body: crate::web::Bytes },
|
||||
Boxed { body: actix_http::body::BoxBody },
|
||||
}
|
||||
|
||||
impl crate::body::MessageBody for AnyBody {
|
||||
type Error = crate::BoxError;
|
||||
|
||||
/// Body size hint.
|
||||
fn size(&self) -> crate::body::BodySize {
|
||||
match self {
|
||||
AnyBody::None => crate::body::BodySize::None,
|
||||
AnyBody::Full { body } => body.size(),
|
||||
AnyBody::Boxed { body } => body.size(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Attempt to pull out the next chunk of body bytes.
|
||||
fn poll_next(
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<Option<Result<crate::web::Bytes, Self::Error>>> {
|
||||
match self.get_mut() {
|
||||
AnyBody::None => std::task::Poll::Ready(None),
|
||||
AnyBody::Full { body } => {
|
||||
let bytes = std::mem::take(body);
|
||||
std::task::Poll::Ready(Some(Ok(bytes)))
|
||||
}
|
||||
AnyBody::Boxed { body } => body.as_pin_mut().poll_next(cx),
|
||||
}
|
||||
}
|
||||
|
||||
fn try_into_bytes(self) -> Result<crate::web::Bytes, Self> {
|
||||
match self {
|
||||
AnyBody::None => Ok(crate::web::Bytes::new()),
|
||||
AnyBody::Full { body } => Ok(body),
|
||||
_ => Err(self),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user