pub struct Body { /* private fields */ }
Implementations§
Source§impl Body
impl Body
Sourcepub fn from_bytes(bytes: impl Into<Bytes>) -> Body
pub fn from_bytes(bytes: impl Into<Bytes>) -> Body
Creates a new Body
from the given bytes.
Sourcepub fn copy_from_slice(slice: impl AsRef<[u8]>) -> Body
pub fn copy_from_slice(slice: impl AsRef<[u8]>) -> Body
Creates a new Body
from the given bytes.
Sourcepub fn from_hyper(body: Incoming) -> Body
pub fn from_hyper(body: Incoming) -> Body
Creates a new Body from a hyper::body::Incoming
.
Sourcepub fn from_sync_reader<R>(reader: R) -> Body
pub fn from_sync_reader<R>(reader: R) -> Body
Creates a new Body from a Read
implementation.
Sourcepub fn from_async_reader<R>(reader: R) -> Body
pub fn from_async_reader<R>(reader: R) -> Body
Creates a new Body from an AsyncRead
implementation.
Sourcepub fn from_async_bytes_streamer<S>(streamer: S) -> Body
pub fn from_async_bytes_streamer<S>(streamer: S) -> Body
Creates a new Body from a Stream<Item=io::Result<Bytes>>
implementation.
Sourcepub fn serialize<S>(value: &S) -> Result<Body, Error>
pub fn serialize<S>(value: &S) -> Result<Body, Error>
Creates a new Body from a serializeable object.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if we know the body is empty, the body still might be empty but we just don’t know it yet
Sourcepub fn set_size_limit(&mut self, size: Option<usize>)
pub fn set_size_limit(&mut self, size: Option<usize>)
Sets a read size limit.
Sourcepub fn set_timeout(&mut self, timeout: Option<Duration>)
pub fn set_timeout(&mut self, timeout: Option<Duration>)
Sets a read timeout, the timer starts counting after you call into_*
Sourcepub async fn into_bytes(self) -> Result<Bytes, Error>
pub async fn into_bytes(self) -> Result<Bytes, Error>
Converts the Body into Bytes.
Sourcepub async fn into_string(self) -> Result<String, Error>
pub async fn into_string(self) -> Result<String, Error>
Converts the Body into a string.
Sourcepub fn into_sync_reader(self) -> BodySyncReader ⓘ
pub fn into_sync_reader(self) -> BodySyncReader ⓘ
Converts the Body into a type that implements Read
.
Sourcepub fn into_async_reader(self) -> BodyAsyncReader
pub fn into_async_reader(self) -> BodyAsyncReader
Converts the Body into a type that implements AsyncRead
.
Sourcepub fn into_async_bytes_streamer(self) -> BodyAsyncBytesStreamer
pub fn into_async_bytes_streamer(self) -> BodyAsyncBytesStreamer
Converts the Body into a type that implements
Stream<Item=io::Result<Bytes>>
.
Sourcepub fn into_http_body(self) -> BodyHttp
pub fn into_http_body(self) -> BodyHttp
Converts the Body into a type that implements hyper::body::Body
.
Sourcepub async fn deserialize<D>(self) -> Result<D, Error>where
D: DeserializeOwned + Send + 'static,
pub async fn deserialize<D>(self) -> Result<D, Error>where
D: DeserializeOwned + Send + 'static,
Converts the Body into a deserializeable type.