Trait actix_web::body::MessageBody [−][src]
pub trait MessageBody {
type Error: Into<Box<dyn Error + 'static, Global>>;
fn size(&self) -> BodySize;
fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Result<Bytes, Self::Error>>>;
fn is_complete_body(&self) -> bool { ... }
fn take_complete_body(&mut self) -> Bytes { ... }
}
Expand description
An interface types that can converted to bytes and used as response bodies.
Associated Types
Required methods
Provided methods
fn is_complete_body(&self) -> bool
fn is_complete_body(&self) -> bool
Returns true if entire body bytes chunk is obtainable in one call to poll_next
.
This method’s implementation should agree with take_complete_body
and should always be
checked before taking the body.
The default implementation returns `false.
fn take_complete_body(&mut self) -> Bytes
fn take_complete_body(&mut self) -> Bytes
Returns the complete chunk of body bytes.
Implementors of this method should note the following:
- It is acceptable to skip the omit checks of
is_complete_body
. The responsibility of performing this check is delegated to the caller. - If the result of
is_complete_body
is conditional, that condition should be given equivalent attention here. - A second call call to
take_complete_body
should return an emptyBytes
or panic. - A call to
poll_next
after callingtake_complete_body
should returnNone
unless the chunk is guaranteed to be empty.
The default implementation panics unconditionally, indicating a control flow bug in the calling code.
Panics
With a correct implementation, panics if called without first checking is_complete_body
.