#[repr(C)]pub enum HttpResult {
Ok(HttpResponse),
Err(HttpError),
}Expand description
The result of an HTTP request, as returned by the shell over the protocol boundary.
§Status codes are not errors
Any completed HTTP exchange — including responses with 4xx or 5xx status codes — is
returned as HttpResult::Ok. Only transport-level failures (the shell could not
reach the server at all) produce HttpResult::Err.
To act on an error status, inspect HttpResponse::status:
match result {
HttpResult::Ok(response) if response.status == 200 => { /* success */ }
HttpResult::Ok(response) if response.status == 404 => { /* not found */ }
HttpResult::Ok(response) if response.status >= 500 => { /* server error */ }
HttpResult::Ok(_) => { /* other status */ }
HttpResult::Err(e) => { /* transport failure: bad URL, IO error, or timeout */ }
}Variants§
Ok(HttpResponse)
The shell completed the HTTP exchange. The response may carry any status code,
including 4xx and 5xx — inspect HttpResponse::status to distinguish them.
Err(HttpError)
The shell could not complete the HTTP exchange due to a transport-level failure.
See HttpError for the possible causes.
Trait Implementations§
Source§impl Clone for HttpResult
impl Clone for HttpResult
Source§fn clone(&self) -> HttpResult
fn clone(&self) -> HttpResult
Returns a duplicate of the value. Read more
1.0.0 · 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 HttpResult
impl Debug for HttpResult
Source§impl<'de> Deserialize<'de> for HttpResult
impl<'de> Deserialize<'de> for HttpResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'ʄ> Facet<'ʄ> for HttpResult
impl<'ʄ> Facet<'ʄ> for HttpResult
Source§impl From<Result<HttpResponse, HttpError>> for HttpResult
impl From<Result<HttpResponse, HttpError>> for HttpResult
Source§fn from(result: Result<HttpResponse>) -> Self
fn from(result: Result<HttpResponse>) -> Self
Converts to this type from the input type.
Source§impl PartialEq for HttpResult
impl PartialEq for HttpResult
Source§impl Serialize for HttpResult
impl Serialize for HttpResult
impl Eq for HttpResult
impl StructuralPartialEq for HttpResult
Auto Trait Implementations§
impl Freeze for HttpResult
impl RefUnwindSafe for HttpResult
impl Send for HttpResult
impl Sync for HttpResult
impl Unpin for HttpResult
impl UnsafeUnpin for HttpResult
impl UnwindSafe for HttpResult
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