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: Body) -> Body
pub fn from_hyper(body: Body) -> Body
Creates a new Body from a hyper::Body
.
sourcepub fn from_sync_reader<R>(reader: R) -> Bodywhere
R: Read + Send + Sync + 'static,
pub fn from_sync_reader<R>(reader: R) -> Bodywhere R: Read + Send + Sync + 'static,
Creates a new Body from a Read
implementation.
sourcepub fn from_async_reader<R>(reader: R) -> Bodywhere
R: AsyncRead + Send + Sync + 'static,
pub fn from_async_reader<R>(reader: R) -> Bodywhere R: AsyncRead + Send + Sync + 'static,
Creates a new Body from an AsyncRead
implementation.
sourcepub fn from_async_bytes_streamer<S>(streamer: S) -> Bodywhere
S: Stream<Item = Result<Bytes, Error>> + Send + Sync + 'static,
pub fn from_async_bytes_streamer<S>(streamer: S) -> Bodywhere S: Stream<Item = Result<Bytes, Error>> + Send + Sync + 'static,
Creates a new Body from a Stream<Item=io::Result<Bytes>>
implementation.
sourcepub fn serialize<S>(value: &S) -> Result<Body, Error>where
S: Serialize + ?Sized,
pub fn serialize<S>(value: &S) -> Result<Body, Error>where S: Serialize + ?Sized,
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.