BodyConversion

Trait BodyConversion 

Source
pub trait BodyConversion: SealedBody
where <Self as Body>::Data: Send,
{ // Provided methods fn into_bytes( self, ) -> impl Future<Output = Result<Bytes, BodyConvertError>> + Send { ... } fn into_vec( self, ) -> impl Future<Output = Result<Vec<u8>, BodyConvertError>> + Send { ... } fn into_string( self, ) -> impl Future<Output = Result<String, BodyConvertError>> + Send { ... } unsafe fn into_string_unchecked( self, ) -> impl Future<Output = Result<String, BodyConvertError>> + Send { ... } fn into_faststr( self, ) -> impl Future<Output = Result<FastStr, BodyConvertError>> + Send { ... } unsafe fn into_faststr_unchecked( self, ) -> impl Future<Output = Result<FastStr, BodyConvertError>> + Send { ... } fn into_json<T>( self, ) -> impl Future<Output = Result<T, BodyConvertError>> + Send where T: DeserializeOwned { ... } }
Expand description

An extend trait for http_body::Body that can converting a body to other types

Provided Methods§

Source

fn into_bytes( self, ) -> impl Future<Output = Result<Bytes, BodyConvertError>> + Send

Consume a body and convert it into Bytes.

Source

fn into_vec( self, ) -> impl Future<Output = Result<Vec<u8>, BodyConvertError>> + Send

Consume a body and convert it into Vec<u8>.

Source

fn into_string( self, ) -> impl Future<Output = Result<String, BodyConvertError>> + Send

Consume a body and convert it into String.

Source

unsafe fn into_string_unchecked( self, ) -> impl Future<Output = Result<String, BodyConvertError>> + Send

Consume a body and convert it into String.

§Safety

It is up to the caller to guarantee that the value really is valid. Using this when the content is invalid causes immediate undefined behavior.

Source

fn into_faststr( self, ) -> impl Future<Output = Result<FastStr, BodyConvertError>> + Send

Consume a body and convert it into FastStr.

Source

unsafe fn into_faststr_unchecked( self, ) -> impl Future<Output = Result<FastStr, BodyConvertError>> + Send

Consume a body and convert it into FastStr.

§Safety

It is up to the caller to guarantee that the value really is valid. Using this when the content is invalid causes immediate undefined behavior.

Source

fn into_json<T>( self, ) -> impl Future<Output = Result<T, BodyConvertError>> + Send

Available on crate feature json only.

Consume a body and convert it into an instance with DeserializeOwned.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> BodyConversion for T
where T: SealedBody, <T as Body>::Data: Send,