Skip to main content

StatusClass

Enum StatusClass 

Source
#[non_exhaustive]
pub enum StatusClass { Informational, Successful, Redirection, ClientError, ServerError, }
Expand description

HTTP ステータスコードのクラス分類 — RFC 9110 Section 15 準拠。

§分類表

バリアント範囲RFC 9110
Informational100..=199§15.2
Successful200..=299§15.3
Redirection300..=399§15.4
ClientError400..=499§15.5
ServerError500..=599§15.6

範囲外 (0..=99, 600..=65535) の値は from_status_codeNone を返す。 本ライブラリ内では ResponseResponseHead の構築時に 100..=599 のバリデーションが効いているため、これらの型を経由する限り 範囲外の値が到達することはない。

RFC 9110 Section 15 (lines 6828-6832) は範囲外の status code を受信した クライアントに対して「5xx (Server Error) として扱うべき (SHOULD)」と勧告している。 from_status_codeNone は「分類不能」を表現しており、この SHOULD 勧告に 従ったフォールバック (例: unwrap_or(StatusClass::ServerError)) は API 利用者の責務。

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.
§

Informational

1xx Informational — RFC 9110 Section 15.2

§

Successful

2xx Successful — RFC 9110 Section 15.3

§

Redirection

3xx Redirection — RFC 9110 Section 15.4

§

ClientError

4xx Client Error — RFC 9110 Section 15.5

§

ServerError

5xx Server Error — RFC 9110 Section 15.6

Implementations§

Source§

impl StatusClass

Source

pub const fn from_status_code(code: u16) -> Option<Self>

u16 のステータスコードから StatusClass を生成する。

範囲外の値 (0..=99, 600..=65535) は None を返す。

Trait Implementations§

Source§

impl Clone for StatusClass

Source§

fn clone(&self) -> StatusClass

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 Debug for StatusClass

Source§

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

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

impl Hash for StatusClass

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for StatusClass

Source§

fn cmp(&self, other: &StatusClass) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for StatusClass

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for StatusClass

Source§

fn partial_cmp(&self, other: &StatusClass) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for StatusClass

Source§

impl Eq for StatusClass

Source§

impl StructuralPartialEq for StatusClass

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.