pub enum ResponsesServerCodes {
Show 26 variants
InternalServerError,
NotImplemented,
BadGateway,
ServiceUnavailable,
GatewayTimeout,
HTTPVersionNotSupported,
VariantAlsoNegotiates,
InsufficientStorage,
LoopDetected,
BandwidthLimitExceeded,
NotExtended,
NetworkAuthenticationRequired,
UnknownError,
WebServerIsDown,
ConnectionTimedOut,
OriginIsUnreachable,
TimeoutOccurred,
SSLHandshakeFailed,
InvalidSSLCertificate,
RailgunError,
SiteIsOverloaded,
SiteIsFrozen,
OriginDNSError,
NoSiteDetected,
NetworkReadTimeoutError,
NetworkConnectTimeoutError,
}Expand description
Enum representing HTTP response status codes and their descriptions. Server errors
Enum representing HTTP response status codes and descriptions for ResponsesServerCodes. This file defines the following methods:
to_http_code: Converts the enum variant to its correspondingHttpCode.get_code: Returns the standard code asu16.from_u16: Constructs an enum variant from a givenu16code (first matching standard, then internal).from_internal_code: Constructs an enum variant from a given internalu16code.as_tuple: Returns a unified tuple representation.as_json: Returns a JSON representation.
§Example
use strum_macros::EnumIter;
use simbld_http::responses::CustomResponse;
use simbld_http::traits::get_code_trait::GetCode;
use simbld_http::responses::ResponsesServerCodes;
let example = ResponsesServerCodes::InternalServerError;
assert_eq!(example.get_code(), 500);
// L'as_tuple retourne une structure UnifiedTuple avec les données du code de réponse
let tuple = example.as_tuple();
assert_eq!(tuple.standard_code, 500);
assert_eq!(tuple.standard_name, "Internal Server Error");Variants§
InternalServerError
NotImplemented
BadGateway
GatewayTimeout
HTTPVersionNotSupported
VariantAlsoNegotiates
InsufficientStorage
LoopDetected
BandwidthLimitExceeded
NotExtended
NetworkAuthenticationRequired
UnknownError
WebServerIsDown
ConnectionTimedOut
OriginIsUnreachable
TimeoutOccurred
SSLHandshakeFailed
InvalidSSLCertificate
RailgunError
SiteIsOverloaded
SiteIsFrozen
OriginDNSError
NoSiteDetected
NetworkReadTimeoutError
NetworkConnectTimeoutError
Implementations§
Source§impl ResponsesServerCodes
impl ResponsesServerCodes
Sourcepub fn get_description(&self) -> &'static str
pub fn get_description(&self) -> &'static str
Returns the description associated with the response code.
Sourcepub fn get_all_data(&self) -> (u16, &'static str, &'static str, &'static str)
pub fn get_all_data(&self) -> (u16, &'static str, &'static str, &'static str)
Returns all data associated with the response code as a tuple.
Sourcepub fn into_response(&self) -> CustomResponse
pub fn into_response(&self) -> CustomResponse
Converts the enum variant into a CustomResponse.
Sourcepub fn to_http_code(&self) -> HttpCode
pub fn to_http_code(&self) -> HttpCode
Converts the enum variant into its corresponding HttpCode.
Sourcepub fn internal_code(&self) -> u16
pub fn internal_code(&self) -> u16
Returns the internal code (u16) of the response.
Sourcepub fn from_u16(code: u16) -> Option<Self>
pub fn from_u16(code: u16) -> Option<Self>
Constructs an enum variant from a given u16 code. It first checks standard codes, then internal codes.
Sourcepub fn from_internal_code(code: u16) -> Option<Self>
pub fn from_internal_code(code: u16) -> Option<Self>
Attempts to create a standardized enumeration variant from the HTTP code `U16 ‘’ which is internal to it. returns “none” if no variant corresponds.
Sourcepub fn as_tuple(&self) -> UnifiedTuple
pub fn as_tuple(&self) -> UnifiedTuple
Returns a unified tuple representation.
Trait Implementations§
Source§impl Clone for ResponsesServerCodes
impl Clone for ResponsesServerCodes
Source§fn clone(&self) -> ResponsesServerCodes
fn clone(&self) -> ResponsesServerCodes
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResponsesServerCodes
impl Debug for ResponsesServerCodes
Source§impl From<ResponsesServerCodes> for (u16, &'static str)
Implementation of the From trait for converting the enum into a tuple (u16, &'static str).
impl From<ResponsesServerCodes> for (u16, &'static str)
Implementation of the From trait for converting the enum into a tuple (u16, &'static str).
Source§fn from(value: ResponsesServerCodes) -> Self
fn from(value: ResponsesServerCodes) -> Self
Source§impl GetCode for ResponsesServerCodes
Implementation of the GetCode trait for the enum.
impl GetCode for ResponsesServerCodes
Implementation of the GetCode trait for the enum.
Source§impl IntoThreeFieldsTuple for ResponsesServerCodes
Implementation for converting the enum into a tuple ’(u16, &’static str, &‘static str)’.
impl IntoThreeFieldsTuple for ResponsesServerCodes
Implementation for converting the enum into a tuple ’(u16, &’static str, &‘static str)’.
fn into_three_fields_tuple(self) -> ThreeFieldsTuple
Source§impl IntoTwoFieldsTuple for ResponsesServerCodes
Implementation for converting the enum into a tuple (u16, &'static str).
impl IntoTwoFieldsTuple for ResponsesServerCodes
Implementation for converting the enum into a tuple (u16, &'static str).
fn into_two_fields_tuple(self) -> TwoFieldsTuple
Source§impl PartialEq for ResponsesServerCodes
impl PartialEq for ResponsesServerCodes
Source§impl Serialize for ResponsesServerCodes
Custom Serialize implementation to include both “type” and “details” fields.
impl Serialize for ResponsesServerCodes
Custom Serialize implementation to include both “type” and “details” fields.