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.
sourcepub async fn as_slice(&mut self) -> Result<&[u8], Error>
pub async fn as_slice(&mut self) -> Result<&[u8], Error>
Converts the body into to Body::Bytes, returning the slice.
Note
If possible, avoid this function as it is really inefficient.
sourcepub async fn deserialize<D>(self) -> Result<D, JsonError> where
D: DeserializeOwned,
pub async fn deserialize<D>(self) -> Result<D, JsonError> where
D: DeserializeOwned,
Tries to deserialize a given Body.
sourcepub async fn copy_to_async_write<W>(self, writer: &mut W) -> Result<(), Error> where
W: AsyncWrite + Unpin,
pub async fn copy_to_async_write<W>(self, writer: &mut W) -> Result<(), Error> where
W: AsyncWrite + Unpin,
Writes the entire body to an AsyncWrite implementer.
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>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
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