Type Alias viz_core::Response

source ·
pub type Response<T = Body> = Response<T>;
Expand description

Represents an HTTP Response.

Aliased Type§

struct Response<T = Body> { /* private fields */ }

Trait Implementations§

source§

impl IntoResponse for Response

source§

fn into_response(self) -> Response

Convert self to HTTP Response.
source§

fn into_error(self) -> Error

Convert self to the Error.
source§

impl ResponseExt for Response

source§

fn content_length(&self) -> Option<u64>

Get the size of this response’s body.
source§

fn content_type(&self) -> Option<Mime>

Get the media type of this response.
source§

fn header<K, T>(&self, key: K) -> Option<T>
where K: AsHeaderName, T: FromStr,

Get a header with the key.
source§

fn ok(&self) -> bool

The response was successful (status in the range 200-299) or not.
source§

async fn download<T>(path: T, name: Option<&str>) -> Result<Self>
where T: AsRef<Path> + Send,

Available on crate feature fs only.
Downloads transfers the file from path as an attachment.
source§

fn empty() -> Response

Creates a response with an empty body.
source§

fn with<B>(body: B, content_type: &'static str) -> Response
where B: Into<Body>,

The response with the specified Content-Type.
source§

fn text<B>(body: B) -> Response
where B: Into<Full<Bytes>>,

The response with text/plain; charset=utf-8 media type.
source§

fn html<B>(body: B) -> Response
where B: Into<Full<Bytes>>,

The response with text/html; charset=utf-8 media type.
source§

fn json<T>(body: T) -> Result<Response, PayloadError>
where T: Serialize,

Available on crate feature json only.
The response with application/javascript; charset=utf-8 media type. Read more
source§

fn stream<S, D, E>(stream: S) -> Response
where S: Stream<Item = Result<D, E>> + Send + 'static, D: Into<Bytes> + 'static, E: Into<BoxError> + 'static,

Responds to a stream.
source§

fn attachment(value: &str) -> Response

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

fn location<T>(location: T) -> Response
where T: AsRef<str>,

The Content-Location header indicates an alternate location for the returned data.
source§

fn redirect<T>(url: T) -> Response
where T: AsRef<str>,

The response redirects to the specified URL.
source§

fn redirect_with_status<T>(url: T, status: StatusCode) -> Response
where T: AsRef<str>,

The response redirects to the specified URL and the status code.
source§

fn see_other<T>(url: T) -> Response
where T: AsRef<str>,

The response redirects to the 303.
source§

fn temporary<T>(url: T) -> Response
where T: AsRef<str>,

The response redirects to the 307.
source§

fn permanent<T>(url: T) -> Response
where T: AsRef<str>,

The response redirects to the 308.