Skip to main content

HandshakeFailure

Struct HandshakeFailure 

Source
pub struct HandshakeFailure {
    pub code: Option<u64>,
    pub code_space: Option<CodeSpace>,
    pub tls_alert: Option<u8>,
    pub reason: String,
}
Expand description

A handshake that failed, with the codes the failure carried still intact.

The reason it is a struct and not another String variant: a peer’s refusal arrives as a number, and flattening it into prose is lossy in a way that only shows up downstream. A TLS alert reaches QUIC as 0x0100 | alert, so no_application_protocol (120) is 0x178, and a caller that wants to distinguish “this relay does not speak our protocol” from “this relay’s certificate expired” (alert 45, 0x12D) was left parsing error messages for digits.

Every field is optional except reason, because not every failure has a code — a timeout and a DNS miss are real outcomes with nothing numeric in them.

Fields§

§code: Option<u64>

The QUIC error code, when the failure carried one.

Meaningless without code_space — the same integer says different things in the two spaces.

§code_space: Option<CodeSpace>

Which space code is a number in.

§tls_alert: Option<u8>

The TLS alert, when the code was a transport code in QUIC’s crypto range.

Derived and not independently sourced: QUIC has no separate field for it, and 0x0100..=0x01ff is how TLS alerts are carried.

§reason: String

What the stack said, for the detail no code carries — which certificate field mismatched, when it expired, which name was expected.

Alert 42 (bad_certificate) is rustls’s catch-all, so telling an expired certificate from a name mismatch still means reading this.

Implementations§

Source§

impl HandshakeFailure

Source

pub fn transport(code: u64, reason: String) -> Self

A failure carrying a transport-space code, with any TLS alert recovered.

Prefer this over a struct literal: it is what keeps tls_alert consistent with code, and a literal can set the two independently.

Source

pub fn application(code: u64, reason: String) -> Self

A failure carrying an application-space close code.

Never carries a TLS alert: application codes are a separate space, and the ones that happen to land in 0x0100..=0x01ff are the trap this constructor exists to close.

Source

pub fn bare(reason: String) -> Self

A failure with nothing numeric in it — a timeout, a DNS miss, a reset.

Source

pub fn alert_of(code: u64) -> Option<u8>

Recover the alert from a transport-space code, if it carries one.

0x0100 | alert is the mapping TLS-over-QUIC defines, so the range is exactly one byte wide and the low byte is the alert. Applying this to an application-space code is a bug — see CodeSpace.

Trait Implementations§

Source§

impl Clone for HandshakeFailure

Source§

fn clone(&self) -> Self

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 HandshakeFailure

Source§

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

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

impl Display for HandshakeFailure

Source§

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

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

impl Eq for HandshakeFailure

Source§

impl PartialEq for HandshakeFailure

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for HandshakeFailure

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 = !

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

fn try_from(value: U) -> Result<T, !>

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