pub enum ResponsesClientCodes {
Show 55 variants
BadRequest,
Unauthorized,
PaymentRequired,
Forbidden,
NotFound,
MethodNotAllowed,
NotAcceptable,
ProxyAuthenticationRequired,
RequestTimeout,
Conflict,
Gone,
LengthRequired,
PreconditionFailed,
ContentTooLarge,
URITooLong,
UnsupportedMediaType,
RangeNotSatisfiable,
ExpectationFailed,
ImATeapot,
PageExpired,
MethodFailure,
MisdirectedRequest,
UnprocessableEntity,
Locked,
FailedDependency,
TooEarly,
UpgradeRequired,
PreconditionRequired,
TooManyRequests,
RequestHeaderFieldsTooLarge,
LoginRequired,
OriginError,
DestinationError,
TooLarge,
SSLCertificateError,
SSLCertificateRequired,
NoCertificate,
LoginTimeout,
OverDataQuota,
NoResponse,
TooManyForwardedIPAddresses,
InternetSecurityError,
RetryWith,
BlockedByWindowsParentalControls,
UnavailableForLegalReasons,
TooManyRecipients,
MethodNotValidInThisState,
UnrecoverableError,
ClientClosedConnexionPrematurely,
RequestHeaderTooLarge,
CertError,
NoCert,
HTTPToHTTPS,
InvalidToken,
ClientClosedRequest,
}Expand description
Enum representing HTTP response status codes and their descriptions. Client errors
Enum representing HTTP response status codes and descriptions for ResponsesClientCodes. 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::ResponsesClientCodes;
let example = ResponsesClientCodes::BadRequest;
assert_eq!(example.get_code(), 400);
// 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, 400);
assert_eq!(tuple.standard_name, "Bad Request");Variants§
BadRequest
PaymentRequired
Forbidden
NotFound
MethodNotAllowed
NotAcceptable
ProxyAuthenticationRequired
RequestTimeout
Conflict
Gone
LengthRequired
PreconditionFailed
ContentTooLarge
URITooLong
UnsupportedMediaType
RangeNotSatisfiable
ExpectationFailed
ImATeapot
PageExpired
MethodFailure
MisdirectedRequest
UnprocessableEntity
Locked
FailedDependency
TooEarly
UpgradeRequired
PreconditionRequired
TooManyRequests
RequestHeaderFieldsTooLarge
LoginRequired
OriginError
DestinationError
TooLarge
SSLCertificateError
SSLCertificateRequired
NoCertificate
LoginTimeout
OverDataQuota
NoResponse
TooManyForwardedIPAddresses
InternetSecurityError
RetryWith
BlockedByWindowsParentalControls
TooManyRecipients
MethodNotValidInThisState
UnrecoverableError
ClientClosedConnexionPrematurely
RequestHeaderTooLarge
CertError
NoCert
HTTPToHTTPS
InvalidToken
ClientClosedRequest
Implementations§
Source§impl ResponsesClientCodes
impl ResponsesClientCodes
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 ResponsesClientCodes
impl Clone for ResponsesClientCodes
Source§fn clone(&self) -> ResponsesClientCodes
fn clone(&self) -> ResponsesClientCodes
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResponsesClientCodes
impl Debug for ResponsesClientCodes
Source§impl From<ResponsesClientCodes> for (u16, &'static str)
Implementation of the From trait for converting the enum into a tuple (u16, &'static str).
impl From<ResponsesClientCodes> for (u16, &'static str)
Implementation of the From trait for converting the enum into a tuple (u16, &'static str).
Source§fn from(value: ResponsesClientCodes) -> Self
fn from(value: ResponsesClientCodes) -> Self
Source§impl GetCode for ResponsesClientCodes
Implementation of the GetCode trait for the enum.
impl GetCode for ResponsesClientCodes
Implementation of the GetCode trait for the enum.
Source§impl IntoThreeFieldsTuple for ResponsesClientCodes
Implementation for converting the enum into a tuple ’(u16, &’static str, &‘static str)’.
impl IntoThreeFieldsTuple for ResponsesClientCodes
Implementation for converting the enum into a tuple ’(u16, &’static str, &‘static str)’.
fn into_three_fields_tuple(self) -> ThreeFieldsTuple
Source§impl IntoTwoFieldsTuple for ResponsesClientCodes
Implementation for converting the enum into a tuple (u16, &'static str).
impl IntoTwoFieldsTuple for ResponsesClientCodes
Implementation for converting the enum into a tuple (u16, &'static str).
fn into_two_fields_tuple(self) -> TwoFieldsTuple
Source§impl PartialEq for ResponsesClientCodes
impl PartialEq for ResponsesClientCodes
Source§impl Serialize for ResponsesClientCodes
Custom Serialize implementation to include both “type” and “details” fields.
impl Serialize for ResponsesClientCodes
Custom Serialize implementation to include both “type” and “details” fields.