pub struct StatusCode(/* private fields */);Expand description
A validated HTTP status code (100–599).
Wraps a u16 with range enforcement at construction time. Reason phrases
are not stored — they are not authoritative application data per HTTP/1.1.
Implementations§
Source§impl StatusCode
impl StatusCode
pub const CONTINUE: Self
pub const SWITCHING_PROTOCOLS: Self
pub const OK: Self
pub const CREATED: Self
pub const NO_CONTENT: Self
pub const RESET_CONTENT: Self
pub const NOT_MODIFIED: Self
pub const MOVED_PERMANENTLY: Self
pub const BAD_REQUEST: Self
pub const FORBIDDEN: Self
pub const NOT_FOUND: Self
pub const METHOD_NOT_ALLOWED: Self
pub const REQUEST_TIMEOUT: Self
pub const PAYLOAD_TOO_LARGE: Self
pub const RANGE_NOT_SATISFIABLE: Self
pub const INTERNAL_SERVER_ERROR: Self
pub const SERVICE_UNAVAILABLE: Self
Sourcepub fn new(code: u16) -> Result<Self, ResponseConstructionError>
pub fn new(code: u16) -> Result<Self, ResponseConstructionError>
Create a validated status code.
§Errors
Returns ResponseConstructionError::InvalidStatus if the code is
outside 100–599. Only standard three-digit HTTP status codes are accepted.
Sourcepub fn is_informational(&self) -> bool
pub fn is_informational(&self) -> bool
Returns true if this is an informational (1xx) status.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns true if this is a success (2xx) status.
Sourcepub fn is_redirection(&self) -> bool
pub fn is_redirection(&self) -> bool
Returns true if this is a redirection (3xx) status.
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Returns true if this is a client-error (4xx) status.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Returns true if this is a server-error (5xx) status.
Sourcepub fn permits_payload_body(&self) -> bool
pub fn permits_payload_body(&self) -> bool
Returns true if this status permits a payload body per RFC 9110.
Informational (1xx), 204 No Content, 205 Reset Content, and 304 Not Modified must not carry a payload body.
Trait Implementations§
Source§impl Clone for StatusCode
impl Clone for StatusCode
Source§fn clone(&self) -> StatusCode
fn clone(&self) -> StatusCode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more