[−][src]Trait tower_web::response::Response
Types that can be returned from resources as responses to HTTP requests.
Implementations of Response
are responsible for encoding the value using
the appropriate content type. The content type may be specific to the type
in question, for example serde_json::Value
implies a content type of
application/json
.
Alternatively, the provided context
may be used to encode the response in
most suitable content-type based on the request context. The content-type is
picked using the following factors:
- The HTTP request's
Accept
header value (not yet implemented). - Any content type specified by the resource using annotations.
- Serialization formats that the application made available to the resource.
Implementations of Response
are able to asynchronously stream the response
body if needed. This is done by setting the HTTP response body to a
BufStream
type that supports streaming.
Associated Types
type Buf: Buf
Data chunk type.
type Body: BufStream<Item = Self::Buf, Error = Error>
The HTTP response body type.
Required Methods
fn into_http<S: Serializer>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
Convert the value into a response future
Implementations on Foreign Types
impl<A, B> Response for Either<A, B> where
A: Response,
B: Response,
[src]
impl<A, B> Response for Either<A, B> where
A: Response,
B: Response,
type Buf = <Self::Body as BufStream>::Item
type Body = Either2<<A as Response>::Body, <B as Response>::Body>
fn into_http<S: Serializer>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
[src]
fn into_http<S: Serializer>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
impl Response for File
[src]
impl Response for File
type Buf = Cursor<BytesMut>
type Body = Map<Self>
fn into_http<S: Serializer>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
[src]
fn into_http<S: Serializer>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
impl Response for Value
[src]
impl Response for Value
type Buf = <Self::Body as BufStream>::Item
type Body = Map<Bytes>
fn into_http<S>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error> where
S: Serializer,
[src]
fn into_http<S>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error> where
S: Serializer,
impl<T: Response> Response for Option<T>
[src]
impl<T: Response> Response for Option<T>
type Buf = T::Buf
type Body = T::Body
fn into_http<S: Serializer>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
[src]
fn into_http<S: Serializer>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
impl<T> Response for Response<T> where
T: BufStream,
[src]
impl<T> Response for Response<T> where
T: BufStream,
type Buf = T::Item
type Body = Map<T>
fn into_http<S: Serializer>(
self,
_: &Context<S>
) -> Result<Response<Self::Body>, Error>
[src]
fn into_http<S: Serializer>(
self,
_: &Context<S>
) -> Result<Response<Self::Body>, Error>
impl Response for String
[src]
impl Response for String
type Buf = Cursor<Vec<u8>>
type Body = Map<String>
fn into_http<S: Serializer>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
[src]
fn into_http<S: Serializer>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
impl Response for &'static str
[src]
impl Response for &'static str
type Buf = Cursor<&'static [u8]>
type Body = Map<&'static str>
fn into_http<S: Serializer>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
[src]
fn into_http<S: Serializer>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error>
impl<T> Response for Vec<T> where
T: Serialize,
[src]
impl<T> Response for Vec<T> where
T: Serialize,
type Buf = <SerdeResponse<Self> as Response>::Buf
type Body = <SerdeResponse<Self> as Response>::Body
fn into_http<S>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error> where
S: Serializer,
[src]
fn into_http<S>(
self,
context: &Context<S>
) -> Result<Response<Self::Body>, Error> where
S: Serializer,