#[non_exhaustive]pub enum Status {
OK,
Created,
Accepted,
NoContent,
BadRequest,
NotFound,
InternalError,
NotImplemented,
}
Expand description
A HTTP status to include in a Response
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
OK
200 OK
Created
201 Created
Accepted
202 Accepted
NoContent
203 No Content
BadRequest
400 Bad Request
NotFound
404 Not Found
InternalError
500 Internal Server Error
NotImplemented
501 Not Implemented
Implementations§
Source§impl Status
impl Status
Sourcepub fn new(status: usize) -> Option<Self>
pub fn new(status: usize) -> Option<Self>
Returns an Option
containing Status
by passing a usize
corresponding to the HTTP status code to it
If the status provided is a valid HTTP status, this function will evaluate to Some
containing Self
If the status provided isn’t valid or implemented yet, this function will return None
§Example
fn main() {
// Generate a new HTTP Status instance (in our case, Status::OK)
let status: Option<Status> = Status::new(200);
assert_eq!(status, Some(Status::OK));
}
Trait Implementations§
impl StructuralPartialEq for Status
Auto Trait Implementations§
impl Freeze for Status
impl RefUnwindSafe for Status
impl Send for Status
impl Sync for Status
impl Unpin for Status
impl UnwindSafe for Status
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