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,Setupall 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.
UnknownRequestand its earlier nameUnknownSubscribeare 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
impl EndpointFault
Sourcepub fn rule(self) -> Option<AboveCodecRule>
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.