pub struct HttpResponse {
pub status: u16,
pub headers: Headers,
pub body: Vec<u8>,
}Expand description
One incoming response.
Fields§
§status: u16§headers: Headers§body: Vec<u8>Implementations§
Source§impl HttpResponse
impl HttpResponse
pub fn new(status: u16, headers: Headers, body: Vec<u8>) -> Self
pub fn is_success(&self) -> bool
pub fn rate_limit(&self, now: OffsetDateTime) -> RateLimit
pub fn text(&self) -> Result<String>
pub fn json<T: DeserializeOwned>(&self) -> Result<T>
Sourcepub fn error_for_status(self, now: OffsetDateTime) -> Result<Self>
pub fn error_for_status(self, now: OffsetDateTime) -> Result<Self>
Turn a non-2xx response into the matching AppError.
This is the single place where an HTTP status becomes a domain error, so 401
and 429 mean the same thing to the UI no matter which service produced them.
Callers that treat a specific status as normal — 404 for “not found yet”,
304 for “not modified” — check HttpResponse::status first.
Trait Implementations§
Source§impl Clone for HttpResponse
impl Clone for HttpResponse
Source§fn clone(&self) -> HttpResponse
fn clone(&self) -> HttpResponse
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HttpResponse
Redacting Debug: a response body can carry a freshly issued access or refresh
token, and a derived Debug would print it verbatim into any log line that formats
a response with ?.
impl Debug for HttpResponse
Redacting Debug: a response body can carry a freshly issued access or refresh
token, and a derived Debug would print it verbatim into any log line that formats
a response with ?.
Auto Trait Implementations§
impl Freeze for HttpResponse
impl RefUnwindSafe for HttpResponse
impl Send for HttpResponse
impl Sync for HttpResponse
impl Unpin for HttpResponse
impl UnsafeUnpin for HttpResponse
impl UnwindSafe for HttpResponse
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