Struct fire_http::Body

source ·
pub struct Body { /* private fields */ }

Implementations§

source§

impl Body

source

pub fn new() -> Body

Creates a new empty Body.

source

pub fn from_bytes(bytes: impl Into<Bytes>) -> Body

Creates a new Body from the given bytes.

source

pub fn copy_from_slice(slice: impl AsRef<[u8]>) -> Body

Creates a new Body from the given bytes.

source

pub fn from_hyper(body: Body) -> Body

Creates a new Body from a hyper::Body.

source

pub fn from_sync_reader<R>(reader: R) -> Bodywhere R: Read + Send + Sync + 'static,

Creates a new Body from a Read implementation.

source

pub fn from_async_reader<R>(reader: R) -> Bodywhere R: AsyncRead + Send + Sync + 'static,

Creates a new Body from an AsyncRead implementation.

source

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.

source

pub fn serialize<S>(value: &S) -> Result<Body, Error>where S: Serialize + ?Sized,

Creates a new Body from a serializeable object.

source

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

source

pub fn len(&self) -> Option<usize>

Returns a length if it is already known.

source

pub fn set_size_limit(&mut self, size: Option<usize>)

Sets a read size limit.

source

pub fn set_timeout(&mut self, timeout: Option<Duration>)

Sets a read timeout, the timer starts counting after you call into_*

source

pub fn take(&mut self) -> Body

Takes the body and replaces it with an empty one.

source

pub async fn into_bytes(self) -> Result<Bytes, Error>

Converts the Body into Bytes.

source

pub async fn into_string(self) -> Result<String, Error>

Converts the Body into a string.

source

pub fn into_sync_reader(self) -> BodySyncReader

Converts the Body into a type that implements Read.

source

pub fn into_async_reader(self) -> BodyAsyncReader

Converts the Body into a type that implements AsyncRead.

source

pub fn into_async_bytes_streamer(self) -> BodyAsyncBytesStreamer

Converts the Body into a type that implements Stream<Item=io::Result<Bytes>>.

source

pub fn into_http_body(self) -> BodyHttp

Converts the Body into a type that implements hyper::body::Body.

source

pub async fn deserialize<D>(self) -> Result<D, Error>where D: DeserializeOwned + Send + 'static,

Converts the Body into a deserializeable type.

Trait Implementations§

source§

impl Debug for Body

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for Body

source§

fn default() -> Body

Returns the “default value” for a type. Read more
source§

impl From<&'static str> for Body

source§

fn from(s: &'static str) -> Body

Converts to this type from the input type.
source§

impl From<Body> for Body

source§

fn from(i: Body) -> Body

Converts to this type from the input type.
source§

impl From<Body> for Response

source§

fn from(body: Body) -> Response

Converts to this type from the input type.
source§

impl From<Bytes> for Body

source§

fn from(b: Bytes) -> Body

Converts to this type from the input type.
source§

impl From<String> for Body

source§

fn from(s: String) -> Body

Converts to this type from the input type.
source§

impl From<Vec<u8>> for Body

source§

fn from(b: Vec<u8>) -> Body

Converts to this type from the input type.
source§

impl IntoResponse for Body

Auto Trait Implementations§

§

impl !RefUnwindSafe for Body

§

impl Send for Body

§

impl Sync for Body

§

impl Unpin for Body

§

impl !UnwindSafe for Body

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<R> IntoRouteResult for Rwhere R: IntoResponse,

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more