1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-30 08:38:16 +02:00

inline trivial body methods

This commit is contained in:
Rob Ede
2021-12-11 16:05:08 +00:00
parent 5b0a50249b
commit b41b346c00
6 changed files with 42 additions and 5 deletions

View File

@@ -23,6 +23,7 @@ pin_project! {
impl<L> EitherBody<L, BoxBody> {
/// Creates new `EitherBody` using left variant and boxed right variant.
#[inline]
pub fn new(body: L) -> Self {
Self::Left { body }
}
@@ -30,11 +31,13 @@ impl<L> EitherBody<L, BoxBody> {
impl<L, R> EitherBody<L, R> {
/// Creates new `EitherBody` using left variant.
#[inline]
pub fn left(body: L) -> Self {
Self::Left { body }
}
/// Creates new `EitherBody` using right variant.
#[inline]
pub fn right(body: R) -> Self {
Self::Right { body }
}
@@ -47,6 +50,7 @@ where
{
type Error = Error;
#[inline]
fn size(&self) -> BodySize {
match self {
EitherBody::Left { body } => body.size(),
@@ -54,6 +58,7 @@ where
}
}
#[inline]
fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
@@ -68,6 +73,7 @@ where
}
}
#[inline]
fn is_complete_body(&self) -> bool {
match self {
EitherBody::Left { body } => body.is_complete_body(),
@@ -75,6 +81,7 @@ where
}
}
#[inline]
fn take_complete_body(&mut self) -> Bytes {
match self {
EitherBody::Left { body } => body.take_complete_body(),