pub struct Response { /* private fields */ }Implementations§
Source§impl Response
impl Response
pub fn new(status: StatusCode, body: impl Into<Bytes>) -> Self
pub fn stream<S>(stream: S) -> Self
Sourcepub fn try_stream<S, E>(stream: S) -> Self
pub fn try_stream<S, E>(stream: S) -> Self
Return a streaming response whose source may fail after headers are committed.
Source errors are deliberately converted to a redacted boundary error. The
connection or HTTP/2 stream terminates and lifecycle observers receive
ResponseBodyOutcome::StreamError.
pub fn text(body: impl Into<Bytes>) -> Self
pub fn status(&self) -> StatusCode
pub fn headers(&self) -> &HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Sourcepub fn body(&self) -> &Bytes
pub fn body(&self) -> &Bytes
Return a buffered response body.
§Panics
Panics when called for a streaming response. Use Self::is_streaming
before inspecting responses that may stream.
pub const fn is_streaming(&self) -> bool
pub fn with_status(self, status: StatusCode) -> Self
Sourcepub fn with_header(
self,
name: impl TryInto<HeaderName>,
value: impl TryInto<HeaderValue>,
) -> Result<Self, InvalidHeader>
pub fn with_header( self, name: impl TryInto<HeaderName>, value: impl TryInto<HeaderValue>, ) -> Result<Self, InvalidHeader>
Append a validated header to the response.
§Errors
Returns InvalidHeader when the name or value cannot be converted to
an HTTP header.
Trait Implementations§
Source§impl IntoResponse for Response
impl IntoResponse for Response
fn into_response(self) -> Response
Auto Trait Implementations§
impl !Freeze for Response
impl !RefUnwindSafe for Response
impl !Sync for Response
impl !UnwindSafe for Response
impl Send 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