pub trait ResponseExt: Sized + Sealed {
Show 19 methods
// Required methods
fn content_length(&self) -> Option<u64>;
fn content_type(&self) -> Option<Mime>;
fn header<K, T>(&self, key: K) -> Option<T>
where K: AsHeaderName,
T: FromStr;
fn ok(&self) -> bool;
fn download<T>(
path: T,
name: Option<&str>,
) -> impl Future<Output = Result<Self, Error>> + Send
where T: AsRef<Path> + Send;
// Provided methods
fn empty() -> Response<Body> { ... }
fn with<B>(body: B, content_type: &str) -> Response<Body>
where B: Into<Body> { ... }
fn text<B>(body: B) -> Response<Body>
where B: Into<Full<Bytes>> { ... }
fn html<B>(body: B) -> Response<Body>
where B: Into<Full<Bytes>> { ... }
fn binary<B>(body: B) -> Response<Body>
where B: Into<Full<Bytes>> { ... }
fn json<T>(body: T) -> Result<Response<Body>, PayloadError>
where T: Serialize { ... }
fn stream<S, D, E>(stream: S) -> Response<Body>
where S: Stream<Item = Result<D, E>> + Send + 'static,
D: Into<Bytes> + 'static,
E: Into<Box<dyn Error + Sync + Send>> + 'static { ... }
fn attachment(value: &str) -> Response<Body> { ... }
fn location<T>(location: T) -> Response<Body>
where T: AsRef<str> { ... }
fn redirect<T>(url: T) -> Response<Body>
where T: AsRef<str> { ... }
fn redirect_with_status<T>(url: T, status: StatusCode) -> Response<Body>
where T: AsRef<str> { ... }
fn see_other<T>(url: T) -> Response<Body>
where T: AsRef<str> { ... }
fn temporary<T>(url: T) -> Response<Body>
where T: AsRef<str> { ... }
fn permanent<T>(url: T) -> Response<Body>
where T: AsRef<str> { ... }
}Expand description
The Response Extension.
Required Methods§
Sourcefn content_length(&self) -> Option<u64>
fn content_length(&self) -> Option<u64>
Get the size of this response’s body.
Sourcefn content_type(&self) -> Option<Mime>
fn content_type(&self) -> Option<Mime>
Get the media type of this response.
Sourcefn header<K, T>(&self, key: K) -> Option<T>where
K: AsHeaderName,
T: FromStr,
fn header<K, T>(&self, key: K) -> Option<T>where
K: AsHeaderName,
T: FromStr,
Get a header with the key.
Provided Methods§
Sourcefn with<B>(body: B, content_type: &str) -> Response<Body>
fn with<B>(body: B, content_type: &str) -> Response<Body>
The response with the specified Content-Type.
Sourcefn json<T>(body: T) -> Result<Response<Body>, PayloadError>where
T: Serialize,
Available on crate feature json only.
fn json<T>(body: T) -> Result<Response<Body>, PayloadError>where
T: Serialize,
json only.The response with application/javascript; charset=utf-8 media type.
§Errors
Throws an error if serialization fails.
Sourcefn attachment(value: &str) -> Response<Body>
fn attachment(value: &str) -> Response<Body>
The Content-Disposition header indicates if the content is expected to be
displayed inline in the browser, that is, as a Web page or as part of a Web page,
or as an attachment, that is downloaded and saved locally.
Sourcefn location<T>(location: T) -> Response<Body>
fn location<T>(location: T) -> Response<Body>
The Content-Location header indicates an alternate location for the returned data.
Sourcefn redirect_with_status<T>(url: T, status: StatusCode) -> Response<Body>
fn redirect_with_status<T>(url: T, status: StatusCode) -> Response<Body>
The response redirects to the specified URL and the status code.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".