Skip to main content

EndpointFault

Enum EndpointFault 

Source
pub enum EndpointFault {
    ThisEndpoint,
    Peer(AboveCodecRule),
    EitherEnd,
}
Expand description

Whose doing one of a draft’s EndpointError variants is.

Returned by EndpointError::fault, which every draft implements exhaustively over its own error type — no wildcard arm, so a variant added to a draft is a compile error beside the sentence it enforces rather than a silent arrival on the wrong side of this answer.

§The question it answers, and the one it does not

The endpoint’s error type mixes two opposite findings under one name, and they read alike as prose. Some of its variants are raised while reading what the peer sent, and they are the peer’s doing. The rest are raised while this endpoint is writing, or refusing to, and they are this side’s — the call failed, nothing reached the wire, and there is nothing to say about the relay.

The code the draft requires be sent is deliberately not carried here. EndpointError::session_error_code already answers it, per draft, quoting the sentence that names it, and a second copy of that table beside this one could disagree with it. crate::dispatch::AnyConnectionError reads both and pairs them.

§Why Some(code) is not the test

It looks like one: a variant the draft answers with a session close is a variant a peer broke a rule to reach. It is not, and the counterexample is concrete. On every draft from 07 to 16, the send path refusing to advertise a ceiling that does not increase — send_max_subscribe_id on drafts 07 through 10, send_max_request_id on 11 through 16 — and a peer sending a ceiling of its own that does not increase are one variant apart: under a single variant session_error_code answers both Some(PROTOCOL_VIOLATION), so a local refusal to write a message publishes as a relay breaking the ceiling rule. That rule is stated of MAX_SUBSCRIBE_ID on drafts 07 through 10 and of MAX_REQUEST_ID on 11 through 16, and the section moves under it four times across the ten: 6.20, 7.20, 8.4, 8.5 and 9.5 — see AboveCodecRule::MaxRequestIdDecreased’s citations for which drafts each of those covers. Each side has a variant of its own for that reason, and this enum is what makes the collision visible.

Variants§

§

ThisEndpoint

This endpoint’s own doing: a call it refused, or state of its own that would not take one.

Nothing reached the wire. A response offered for a request the draft requires be refused, a message handed to the wrong writer, an alias this endpoint was asked to give to a second track, a session that is closed or draining. Every one of them is evidence about this build and none of them is evidence about a peer, so all of them reach crate::dispatch::ErrorCause::Endpoint, which crate::dispatch::AnyConnectionError::is_local counts.

A peer can cause one of these without having broken anything this endpoint may name it for. A request whose filters the draft says to reject is refused here when a REQUEST_OK is offered for it, because the refusal is a reply and a reply needs the request to have been taken first; what failed is this side’s attempt to accept it.

§

Peer(AboveCodecRule)

The peer did what the draft forbids, and this endpoint caught it reading.

§

EitherEnd

Both are reachable through this variant and the variant cannot say which.

Answered like Self::ThisEndpoint — reaching crate::dispatch::ErrorCause::Endpoint, counted by crate::dispatch::AnyConnectionError::is_local — because that is the safe direction and the one this facade already took: a failure that has not been told apart is not evidence against a relay.

Kept as its own answer rather than folded into ThisEndpoint so that the ones still to be told apart are a list the compiler can produce. There are two kinds:

  • The state machines. Session, Subscription, Fetch, Namespace, TrackStatus, PublishFlow, Setup all render as invalid transition from X on event Y, and the same sentence covers this endpoint declining to send a message in a state that forbids it and a peer having sent one. Telling those apart is a pass of its own.
  • The unknown-request errors. UnknownRequest and its earlier name UnknownSubscribe are raised on more than sixty call sites per draft, about half of them reading a response that names an id this session never issued — the peer’s doing — and about half of them a caller naming one of its own that does not exist.

Neither is published as anything: both answer is_local true. What this enum adds is that they are countable.

Implementations§

Source§

impl EndpointFault

Source

pub fn rule(self) -> Option<AboveCodecRule>

The rule this fault names, or None where it names none.

None for both of the non-peer answers, which is the same collapse crate::dispatch::ErrorCause performs: neither is grounds to name a relay, and a caller that needs to tell them apart has the variant.

Trait Implementations§

Source§

impl Clone for EndpointFault

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 Copy for EndpointFault

Source§

impl Debug for EndpointFault

Source§

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

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

impl Eq for EndpointFault

Source§

impl PartialEq for EndpointFault

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 EndpointFault

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