Skip to main content

Status

Struct Status 

Source
pub struct Status(/* private fields */);
Expand description

A response status code (RFC 9110 §15).

Three decimal digits and nothing more: :status carries the code alone (RFC 9114 §4.3.2), and the reason phrase that followed it in HTTP/1.1 has no HTTP/3 representation at all. The digits are what is stored, because they are what goes on the wire.

Only the codes this server sends have names. A code with no constant here is one no path reaches, and adding one is how a new answer gets named rather than spelled as a literal at the place it is sent from.

Implementations§

Source§

impl Status

Source

pub const OK: Self

200 OK: the tunnel is open (RFC 9114 §4.4).

Source

pub const BAD_REQUEST: Self

400 Bad Request: the request is not one this proxy can act on.

Source

pub const FORBIDDEN: Self

403 Forbidden: refused by this proxy’s own policy (decision D11).

Source

pub const PROXY_AUTHENTICATION_REQUIRED: Self

407 Proxy Authentication Required (RFC 9110 §15.5.8).

Source

pub const REQUEST_HEADER_FIELDS_TOO_LARGE: Self

431 Request Header Fields Too Large (RFC 6585 §5, RFC 9114 §4.2.2).

Source

pub const INTERNAL_SERVER_ERROR: Self

500 Internal Server Error: a fault on this side of the tunnel.

Source

pub const NOT_IMPLEMENTED: Self

501 Not Implemented: a method or :protocol this proxy does not serve.

Source

pub const BAD_GATEWAY: Self

502 Bad Gateway: the target refused the connection or could not be looked up (RFC 9209 §2.3.2).

Source

pub const SERVICE_UNAVAILABLE: Self

503 Service Unavailable: the target could not be reached at all, or this proxy is at a limit (RFC 9209 §2.3.2).

Source

pub const GATEWAY_TIMEOUT: Self

504 Gateway Timeout: the target never answered (RFC 9209 §2.3.2).

Source

pub fn parse(bytes: &[u8]) -> Option<Self>

Reads a :status value.

None for anything that is not three digits with a non-zero first one, which is the shape of every code RFC 9110 §15 defines.

A server reads no responses, so this exists for the suite’s client. It is here rather than there because a status is a status at both ends of the wire.

Source

pub fn as_str(&self) -> &str

The three digits, as :status carries them.

§Panics

Never in practice: every constant here is an ASCII literal and Self::parse accepts nothing else, so the digits cannot be anything a str will not hold. The check is kept rather than made unchecked because it costs three comparisons on a path that writes a response.

Trait Implementations§

Source§

impl Clone for Status

Source§

fn clone(&self) -> Status

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 Status

Source§

impl Debug for Status

Source§

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

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

impl Display for Status

Source§

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

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

impl Eq for Status

Source§

impl Hash for Status

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 PartialEq for Status

Source§

fn eq(&self, other: &Status) -> 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 StructuralPartialEq for Status

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.

§

impl<T> Instrument for T

§

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

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

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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