#[non_exhaustive]pub enum StatusClass {
Informational,
Successful,
Redirection,
ClientError,
ServerError,
}Expand description
HTTP ステータスコードのクラス分類 — RFC 9110 Section 15 準拠。
§分類表
| バリアント | 範囲 | RFC 9110 |
|---|---|---|
Informational | 100..=199 | §15.2 |
Successful | 200..=299 | §15.3 |
Redirection | 300..=399 | §15.4 |
ClientError | 400..=499 | §15.5 |
ServerError | 500..=599 | §15.6 |
範囲外 (0..=99, 600..=65535) の値は from_status_code で None を返す。
本ライブラリ内では Response と ResponseHead の構築時に
100..=599 のバリデーションが効いているため、これらの型を経由する限り
範囲外の値が到達することはない。
RFC 9110 Section 15 (lines 6828-6832) は範囲外の status code を受信した
クライアントに対して「5xx (Server Error) として扱うべき (SHOULD)」と勧告している。
from_status_code の None は「分類不能」を表現しており、この 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
impl StatusClass
Sourcepub const fn from_status_code(code: u16) -> Option<Self>
pub const fn from_status_code(code: u16) -> Option<Self>
u16 のステータスコードから StatusClass を生成する。
範囲外の値 (0..=99, 600..=65535) は None を返す。
Trait Implementations§
Source§impl Clone for StatusClass
impl Clone for StatusClass
Source§fn clone(&self) -> StatusClass
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StatusClass
impl Debug for StatusClass
Source§impl Hash for StatusClass
impl Hash for StatusClass
Source§impl Ord for StatusClass
impl Ord for StatusClass
Source§fn cmp(&self, other: &StatusClass) -> Ordering
fn cmp(&self, other: &StatusClass) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for StatusClass
impl PartialEq for StatusClass
Source§fn eq(&self, other: &StatusClass) -> bool
fn eq(&self, other: &StatusClass) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for StatusClass
impl PartialOrd for StatusClass
impl Copy for StatusClass
impl Eq for StatusClass
impl StructuralPartialEq for StatusClass
Auto Trait Implementations§
impl Freeze for StatusClass
impl RefUnwindSafe for StatusClass
impl Send for StatusClass
impl Sync for StatusClass
impl Unpin for StatusClass
impl UnsafeUnpin for StatusClass
impl UnwindSafe for StatusClass
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more