via::response

Struct Response

Source
pub struct Response { /* private fields */ }

Implementations§

Source§

impl Response

Source

pub fn into_parts(self) -> (Parts, ResponseBody)

Consumes the response and returns a tuple containing the component parts of the response and the response body.

Source

pub fn map<F, T>(self, map: F) -> Self
where F: FnOnce(ResponseBody) -> T, T: Body<Data = Bytes, Error = BoxError> + Send + Sync + 'static,

Consumes the response returning a new response with body mapped to the return type of the provided closure map.

Source

pub fn body(&self) -> &ResponseBody

Source

pub fn body_mut(&mut self) -> &mut ResponseBody

Source

pub fn cookies(&self) -> &CookieJar

Returns a reference to the response cookies.

Source

pub fn cookies_mut(&mut self) -> &mut CookieJar

Returns a mutable reference to the response cookies.

Source

pub fn headers(&self) -> &HeaderMap

Source

pub fn headers_mut(&mut self) -> &mut HeaderMap

Source

pub fn set_header(&mut self, name: HeaderName, value: HeaderValue)

A shorthand method for self.headers_mut().insert(name, value).

Source

pub fn status(&self) -> StatusCode

Source

pub fn status_mut(&mut self) -> &mut StatusCode

Source

pub fn set_status(&mut self, status: StatusCode)

A shorthand method for *self.status_mut() = status.

Source

pub fn version(&self) -> Version

Source§

impl Response

Source

pub fn new(body: ResponseBody) -> Self

Source

pub fn build() -> ResponseBuilder

Source

pub fn html(body: String) -> Self

Source

pub fn text(body: String) -> Self

Source

pub fn json<T>(body: &T) -> Result<Response, Error>
where T: Serialize,

Source

pub fn stream<T, E>(body: T) -> Self
where T: Body<Data = Bytes, Error = BoxError> + Send + Sync + 'static,

Create a response from a stream of Result<Frame<Bytes>, Error>.

Source

pub fn from_parts(parts: Parts, body: ResponseBody) -> Self

Source

pub fn bad_request() -> Self

Returns a new Error from the provided source that will generate a Response with a 400 Bad Request status.

Source

pub fn unauthorized() -> Self

Returns a new Error from the provided source that will generate a Response with a 401 Unauthorized status.

Source

pub fn payment_required() -> Self

Returns a new Error from the provided source that will generate a Response with a 402 Payment Required status.

Source

pub fn forbidden() -> Self

Returns a new Error from the provided source that will generate a Response with a 403 Forbidden status.

Source

pub fn not_found() -> Self

Returns a new Error from the provided source that will generate a Response with a 404 Not Found status.

Source

pub fn method_not_allowed() -> Self

Returns a new Error from the provided source that will generate a Response with a 405 Method Not Allowed status.

Source

pub fn not_acceptable() -> Self

Returns a new Error from the provided source that will generate a Response with a 406 Not Acceptable status.

Source

pub fn proxy_authentication_required() -> Self

Returns a new Error from the provided source that will generate a Response with a 407 Proxy Authentication Required status.

Source

pub fn request_timeout() -> Self

Returns a new Error from the provided source that will generate a Response with a 408 Request Timeout status.

Source

pub fn conflict() -> Self

Returns a new Error from the provided source that will generate a Response with a 409 Conflict status.

Source

pub fn gone() -> Self

Returns a new Error from the provided source that will generate a Response with a 410 Gone status.

Source

pub fn length_required() -> Self

Returns a new Error from the provided source that will generate a Response with a 411 Length Required status.

Source

pub fn precondition_failed() -> Self

Returns a new Error from the provided source that will generate a Response with a 412 Precondition Failed status.

Source

pub fn payload_too_large() -> Self

Returns a new Error from the provided source that will generate a Response with a 413 Payload Too Large status.

Source

pub fn uri_too_long() -> Self

Returns a new Error from the provided source that will generate a Response with a 414 URI Too Long status.

Source

pub fn unsupported_media_type() -> Self

Returns a new Error from the provided source that will generate a Response with a 415 Unsupported Media Type status.

Source

pub fn range_not_satisfiable() -> Self

Returns a new Error from the provided source that will generate a Response with a 416 Range Not Satisfiable status.

Source

pub fn expectation_failed() -> Self

Returns a new Error from the provided source that will generate a Response with a 417 Expectation Failed status.

Source

pub fn im_a_teapot() -> Self

Returns a new Error from the provided source that will generate a Response with a 418 I'm a teapot status.

Source

pub fn misdirected_request() -> Self

Returns a new Error from the provided source that will generate a Response with a 421 Misdirected Request status.

Source

pub fn unprocessable_entity() -> Self

Returns a new Error from the provided source that will generate a Response with a 422 Unprocessable Entity status.

Source

pub fn locked() -> Self

Returns a new Error from the provided source that will generate a Response with a 423 Locked status.

Source

pub fn failed_dependency() -> Self

Returns a new Error from the provided source that will generate a Response with a 424 Failed Dependency status.

Source

pub fn upgrade_required() -> Self

Returns a new Error from the provided source that will generate a Response with a 426 Upgrade Required status.

Source

pub fn precondition_required() -> Self

Returns a new Error from the provided source that will generate a Response with a 428 Precondition Required status.

Source

pub fn too_many_requests() -> Self

Returns a new Error from the provided source that will generate a Response with a 429 Too Many Requests status.

Source

pub fn request_header_fields_too_large() -> Self

Returns a new Error from the provided source that will generate a Response with a 431 Request Header Fields Too Large status.

Returns a new Error from the provided source that will generate a Response with a 451 Unavailable For Legal Reasons status.

Source

pub fn internal_server_error() -> Self

Returns a new Error from the provided source that will generate a Response with a 500 Internal Server Error status.

Source

pub fn not_implemented() -> Self

Returns a new Error from the provided source that will generate a Response with a 501 Not Implemented status.

Source

pub fn bad_gateway() -> Self

Returns a new Error from the provided source that will generate a Response with a 502 Bad Gateway status.

Source

pub fn service_unavailable() -> Self

Returns a new Error from the provided source that will generate a Response with a 503 Service Unavailable status.

Source

pub fn gateway_timeout() -> Self

Returns a new Error from the provided source that will generate a Response with a 504 Gateway Timeout status.

Source

pub fn http_version_not_supported() -> Self

Returns a new Error from the provided source that will generate a Response with a 505 HTTP Version Not Supported status.

Source

pub fn variant_also_negotiates() -> Self

Returns a new Error from the provided source that will generate a Response with a 506 Variant Also Negotiates status.

Source

pub fn insufficient_storage() -> Self

Returns a new Error from the provided source that will generate a Response with a 507 Insufficient Storage status.

Source

pub fn loop_detected() -> Self

Returns a new Error from the provided source that will generate a Response with a 508 Loop Detected status.

Source

pub fn not_extended() -> Self

Returns a new Error from the provided source that will generate a Response with a 510 Not Extended status.

Source

pub fn network_authentication_required() -> Self

Returns a new Error from the provided source that will generate a Response with a 511 Network Authentication Required status.

Trait Implementations§

Source§

impl Debug for Response

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Response

Source§

fn default() -> Self

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

impl From<Error> for Response

Source§

fn from(error: Error) -> Response

Converts to this type from the input type.
Source§

impl From<Response<ResponseBody>> for Response

Source§

fn from(response: Response<ResponseBody>) -> Self

Converts to this type from the input type.
Source§

impl IntoResponse for Response

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.