pub struct Response {
pub status: Status,
pub headers: Headers,
pub body: Vec<u8>,
/* private fields */
}Expand description
An outgoing response.
Fields§
§status: Status§headers: Headers§body: Vec<u8>Implementations§
Source§impl Response
impl Response
pub fn new(status: Status) -> Self
Sourcepub fn upgrading(self, upgrade: impl Upgrade) -> Self
pub fn upgrading(self, upgrade: impl Upgrade) -> Self
Answer 101 and hand the connection to another protocol.
The caller sets whatever headers the new protocol’s handshake requires; this only arranges for the socket to be handed over afterwards.
Sourcepub fn take_upgrade(&mut self) -> Option<Upgrader>
pub fn take_upgrade(&mut self) -> Option<Upgrader>
Take the upgrade out of a dispatched response.
Public so a test can drive an upgrade through the router rather than only over a real socket.
pub fn ok() -> Self
pub fn no_content() -> Self
pub fn not_found() -> Self
Sourcepub fn redirect(location: impl Into<String>) -> Self
pub fn redirect(location: impl Into<String>) -> Self
A 302 redirect. Use Response::see_other after a form submission so
the browser switches to GET.
pub fn see_other(location: impl Into<String>) -> Self
pub fn json(value: impl Into<Json>) -> Self
pub fn html(body: impl Into<String>) -> Self
pub fn text(body: impl Into<String>) -> Self
pub fn with_status(self, status: impl Into<Status>) -> Self
pub fn with_header(self, name: &str, value: impl Into<String>) -> Self
pub fn with_body(self, body: impl Into<Vec<u8>>) -> Self
pub fn with_json(self, value: impl Into<Json>) -> Self
pub fn with_html(self, body: impl Into<String>) -> Self
pub fn with_text(self, body: impl Into<String>) -> Self
Expire a cookie on the client.
pub fn body_string(&self) -> String
Trait Implementations§
Source§impl IntoResponse for Response
impl IntoResponse for Response
fn into_response(self) -> Response
Auto Trait Implementations§
impl !RefUnwindSafe for Response
impl !UnwindSafe for Response
impl Freeze for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more