pub struct Body(_);
Expand description

The trillium representation of a http body. This can contain either &'static [u8] content, Vec<u8> content, or a boxed AsyncRead type.

Implementations

Construct a new body from a streaming [AsyncRead] source. If you have the body content in memory already, prefer Body::new_static or one of the From conversions.

Construct a fixed-length Body from a Vec<u8> or &'static [u8].

Retrieve a borrow of the static content in this body. If this body is a streaming body or an empty body, this will return None.

Transform this Body into a dyn AsyncRead. This will wrap static content in a [Cursor]. Note that this is different from reading directly from the Body, which includes chunked encoding.

Consume this body and return the full content. If the body was constructed with [Body::new_streaming], this will read the entire streaming body into memory, awaiting the streaming source’s completion. This function will return an error if a streaming body has already been read to completion.

Errors

This returns an error variant if either of the following conditions are met:

  • there is an io error when reading from the underlying transport such as a disconnect
  • the body has already been read to completion

Retrieve the number of bytes that have been read from this body

returns the content length of this body, if known and available.

determine if the this body represents no data

determine if the this body represents static content

determine if the this body represents streaming content

Trait Implementations

Attempt to read from the AsyncRead into buf. Read more

Attempt to read from the AsyncRead into bufs using vectored IO operations. Read more

Formats the value using the given formatter. Read more

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

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Reads some bytes from the byte stream. Read more

Like [read()][AsyncReadExt::read()], except it reads into a slice of buffers. Read more

Reads the entire contents and appends them to a Vec. Read more

Reads the entire contents and appends them to a String. Read more

Reads the exact number of bytes required to fill buf. Read more

Creates an adapter which will read at most limit bytes from it. Read more

Converts this [AsyncRead] into a [Stream] of bytes. Read more

Creates an adapter which will chain this stream with another. Read more

Boxes the reader and changes its type to dyn AsyncRead + Send + 'a. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.