Skip to content

Commit

Permalink
remove hidden anybody
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Dec 18, 2021
1 parent 84ea9e7 commit 5c53db1
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
}

0 comments on commit 5c53db1

Please sign in to comment.