pub enum ResponsesServiceCodes {
Show 16 variants
ReadingError,
ConnectionError,
ReadingTimeExpired,
SSLHandshakeFailed,
AnotherReadingError,
FBAAnomaly,
CodingError,
RedirectWithoutRedirectURL,
DNSLookupFailed,
SyntacticallyIncorrectURL,
LostConnection,
WriteTimeout,
SelectionFailed,
WriteError,
IncompleteBlockHeader,
UnexpectedError,
}Expand description
Enum representing HTTP response status codes and their descriptions. Service responses
Enum representing HTTP response status codes and descriptions for ResponsesServiceCodes. 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::ResponsesServiceCodes;
let example = ResponsesServiceCodes::ReadingError;
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§
ReadingError
ConnectionError
ReadingTimeExpired
SSLHandshakeFailed
AnotherReadingError
FBAAnomaly
CodingError
RedirectWithoutRedirectURL
DNSLookupFailed
SyntacticallyIncorrectURL
LostConnection
WriteTimeout
SelectionFailed
WriteError
IncompleteBlockHeader
UnexpectedError
Implementations§
Source§impl ResponsesServiceCodes
impl ResponsesServiceCodes
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 ResponsesServiceCodes
impl Clone for ResponsesServiceCodes
Source§fn clone(&self) -> ResponsesServiceCodes
fn clone(&self) -> ResponsesServiceCodes
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResponsesServiceCodes
impl Debug for ResponsesServiceCodes
Source§impl From<ResponsesServiceCodes> for (u16, &'static str)
Implementation of the From trait for converting the enum into a tuple (u16, &'static str).
impl From<ResponsesServiceCodes> for (u16, &'static str)
Implementation of the From trait for converting the enum into a tuple (u16, &'static str).
Source§fn from(value: ResponsesServiceCodes) -> Self
fn from(value: ResponsesServiceCodes) -> Self
Source§impl GetCode for ResponsesServiceCodes
Implementation of the GetCode trait for the enum.
impl GetCode for ResponsesServiceCodes
Implementation of the GetCode trait for the enum.
Source§impl IntoThreeFieldsTuple for ResponsesServiceCodes
Implementation for converting the enum into a tuple ’(u16, &’static str, &‘static str)’.
impl IntoThreeFieldsTuple for ResponsesServiceCodes
Implementation for converting the enum into a tuple ’(u16, &’static str, &‘static str)’.
fn into_three_fields_tuple(self) -> ThreeFieldsTuple
Source§impl IntoTwoFieldsTuple for ResponsesServiceCodes
Implementation for converting the enum into a tuple (u16, &'static str).
impl IntoTwoFieldsTuple for ResponsesServiceCodes
Implementation for converting the enum into a tuple (u16, &'static str).
fn into_two_fields_tuple(self) -> TwoFieldsTuple
Source§impl PartialEq for ResponsesServiceCodes
impl PartialEq for ResponsesServiceCodes
Source§impl Serialize for ResponsesServiceCodes
Custom Serialize implementation to include both “type” and “details” fields.
impl Serialize for ResponsesServiceCodes
Custom Serialize implementation to include both “type” and “details” fields.