Struct fire_http::body::BodyWithTimeout
source · [−]pub struct BodyWithTimeout { /* private fields */ }Expand description
Adds a timeout to any Body.
Implementations
sourceimpl BodyWithTimeout
impl BodyWithTimeout
sourcepub fn from_hyper_body(
body: Body,
max_size: usize,
timeout: Duration
) -> BodyWithTimeout
pub fn from_hyper_body(
body: Body,
max_size: usize,
timeout: Duration
) -> BodyWithTimeout
Creates a BodyWithTimeout from a hyper::Body.
Panics while reading
If the body was already read more than the max_size or the max_size is 0.
sourcepub fn take(&mut self) -> BodyWithTimeout
pub fn take(&mut self) -> BodyWithTimeout
Creates a new BodyWithTimeout leaving the old one, with an empty Body.
sourcepub fn set_size_limit(&mut self, max_size: usize) -> bool
pub fn set_size_limit(&mut self, max_size: usize) -> bool
Sets a read size limit to the HyperBody. Returns true if the size limit was set.
Note
Works only with the hyper_body feature.
When the size limit is reached an io::Error::Other with SizeLimitReached
is returned.
Panics while reading
If the body was already read more than the max_size or the max_size is 0.
sourcepub fn set_timeout(&mut self, timeout: Duration)
pub fn set_timeout(&mut self, timeout: Duration)
Sets the timeout.
sourcepub async fn into_more_bytes(self) -> Result<MoreBytes, Error>
pub async fn into_more_bytes(self) -> Result<MoreBytes, Error>
Converts the body into MoreBytes returning an error if reading failed or the size limit was reached.
sourcepub async fn into_string(self) -> Result<String, Error>
pub async fn into_string(self) -> Result<String, Error>
Converts the body into a String.
Note
If possible, avoid this function as it is really inefficient.
For tests or quick debugging however it is quite suitable.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for BodyWithTimeout
impl Send for BodyWithTimeout
impl Sync for BodyWithTimeout
impl Unpin for BodyWithTimeout
impl !UnwindSafe for BodyWithTimeout
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more