Skip to main content

ResponsesServerCodes

Enum ResponsesServerCodes 

Source
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 corresponding HttpCode.
  • get_code: Returns the standard code as u16.
  • from_u16: Constructs an enum variant from a given u16 code (first matching standard, then internal).
  • from_internal_code: Constructs an enum variant from a given internal u16 code.
  • 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

§

ServiceUnavailable

§

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

Source

pub fn get_description(&self) -> &'static str

Returns the description associated with the response code.

Source

pub fn get_code(&self) -> u16

Returns the standard code (u16) of the response.

Source

pub fn get_name(&self) -> &'static str

Implementation of the get_name method for the enum.

Source

pub fn get_data(&self) -> &'static str

Returns the data associated with the response code.

Source

pub fn get_all_data(&self) -> (u16, &'static str, &'static str, &'static str)

Returns all data associated with the response code as a tuple.

Source

pub fn into_response(&self) -> CustomResponse

Converts the enum variant into a CustomResponse.

Source

pub fn to_http_code(&self) -> HttpCode

Converts the enum variant into its corresponding HttpCode.

Source

pub fn internal_code(&self) -> u16

Returns the internal code (u16) of the response.

Source

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.

Source

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.

Source

pub fn as_tuple(&self) -> UnifiedTuple

Returns a unified tuple representation.

Source

pub fn as_json(&self) -> Value

Returns a JSON representation of the response code.

Trait Implementations§

Source§

impl Clone for ResponsesServerCodes

Source§

fn clone(&self) -> ResponsesServerCodes

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ResponsesServerCodes

Source§

impl Debug for ResponsesServerCodes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Converts to this type from the input type.
Source§

impl GetCode for ResponsesServerCodes

Implementation of the GetCode trait for the enum.

Source§

fn get_code(&self) -> u16

Source§

impl GetDescription for ResponsesServerCodes

Source§

fn get_description_field(&self, field: &str) -> Option<&'static str>

Source§

impl IntoEnumIterator for ResponsesServerCodes

Source§

impl IntoThreeFieldsTuple for ResponsesServerCodes

Implementation for converting the enum into a tuple ’(u16, &’static str, &‘static str)’.

Source§

impl IntoTwoFieldsTuple for ResponsesServerCodes

Implementation for converting the enum into a tuple (u16, &'static str).

Source§

impl PartialEq for ResponsesServerCodes

Source§

fn eq(&self, other: &ResponsesServerCodes) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ResponsesServerCodes

Custom Serialize implementation to include both “type” and “details” fields.

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ResponsesServerCodes

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more