pub trait Response {
type Buf: Buf;
type Body: BufStream<Item = Self::Buf, Error = Error>;
// Required method
fn into_http<S: Serializer>(
self,
context: &Context<'_, S>,
) -> Result<Response<Self::Body>, Error>;
}Expand description
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
Acceptheader 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.
Required Associated Types§
Required Methods§
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.