Skip to main content

ConnectionError

Enum ConnectionError 

Source
pub enum ConnectionError {
Show 21 variants Endpoint(EndpointError), Codec(CodecError), Transport(TransportError), VarInt(VarIntError), NoControlStream, UnexpectedEnd, TruncatedObject, StreamFinished, InvalidAddress(String), TlsConfig(String), DataStreamState(&'static str), ControlMessageNarrowing, RequestOnControlStream(MessageType), RequestStreamMessageOnControlStream(MessageType), MalformedTrackDatagram { track_alias: u64, error: CodecError, }, PayloadOnStatusDatagram { object_id: u64, payload_len: usize, status: Option<ObjectStatus>, }, PropertiesOnNonNormalStatus { object_id: u64, properties_len: usize, status: ObjectStatus, }, NonRequestOnRequestStream(MessageType), RespondedToOwnRequest(u64), FinBeforeResponse(u64), FinBeforePublishDone(u64),
}
Expand description

Errors from the connection layer.

Variants§

§

Endpoint(EndpointError)

Endpoint state machine error.

§

Codec(CodecError)

Wire codec error.

§

Transport(TransportError)

Transport-level error.

§

VarInt(VarIntError)

Variable-length integer decoding error.

§

NoControlStream

Control stream was not opened.

§

UnexpectedEnd

Stream ended before a complete message was read.

§

TruncatedObject

A data stream ended with a FIN inside an Object.

draft-23 Section 11.3: “If a stream ends gracefully (i.e., the stream terminates with a FIN) in the middle of a serialized Object, the receiver SHOULD close the session with TRUNCATED_OBJECT.” A FIN between two Objects is ConnectionError::UnexpectedEnd.

§

StreamFinished

Stream was finished by the peer.

§

InvalidAddress(String)

Invalid server address string.

§

TlsConfig(String)

TLS configuration error.

§

DataStreamState(&'static str)

Data stream used out of order (e.g. object before header).

§

ControlMessageNarrowing

A control message this build decoded for draft-23 and then could not narrow to draft-23’s own message type.

Unreachable, and that is not the same as harmless. read_control decodes with this connection’s own draft, so the AnyControlMessage it hands back can only carry this draft’s variant — but the narrowing arm is compiled in every configuration anyway, under #[allow(unreachable_patterns)] rather than a cfg naming the other drafts, because such a list has to be edited in every per-draft module whenever a draft is added and a copy that omits one leaves the match non-exhaustive.

Spelled as CodecError::UnknownMessageType(0) it would not stay inert: every draft’s codec_session_error_code answers that variant with a session close. So the day the narrowing did fail, this build’s own defect would reach a caller as the peer sent a control message type this draft does not assign, and the session must be closed with a Protocol Violation — carrying 0x00 as the codepoint that proved it. A conformance report reading that publishes a named, well-evidenced accusation against a relay for something no relay did.

A variant of its own is what stops that. draft_specific_cause answers it LocalRefusal, the facade turns that into ErrorCause::Facade, and nothing downstream can read a rule out of a cause that says nothing reached the wire. What is pinned is the consequence rather than the unreachability: nothing pins the arm’s reachability, which is exactly why the consequence must not be an accusation.

§

RequestOnControlStream(MessageType)

A message that begins a request stream was handed to Connection::send_control. Nothing was written.

§

RequestStreamMessageOnControlStream(MessageType)

A message draft-23 places on a request stream was handed to Connection::send_control. Nothing was written.

Distinct from ConnectionError::RequestOnControlStream, which is about a message that would begin a request stream of its own. This one is about a message that belongs on a request stream already open, and so has no meaning without one around it.

§

MalformedTrackDatagram

The codec refused a datagram with CodecError::MalformedTrack, for a Prior Group ID Gap or Prior Object ID Gap fault (draft-23 Section 10.8, draft-23 Section 10.9), or with CodecError::MalformedObjectProperties, for a property block that does not parse (draft-23 Section 10.7). Either makes the datagram’s track malformed.

Carries the datagram’s Track Alias, which the codec’s error does not name, so Connection::requests_to_cancel can name the requests to cancel. The session stays open.

Fields

§track_alias: u64

The Track Alias the datagram named.

§error: CodecError

The codec’s refusal.

§

PayloadOnStatusDatagram

A datagram carrying an Object Status arrived with bytes after its header. Draft-23 Section 11.1.1: “An Object MUST have an empty payload unless its Object Status value is registered as permitting a payload in the Object Status registry” Section 11.2.1 says the same thing about the framing: a datagram with the STATUS bit set “is present and there is no Object Payload.”

The codec cannot see this. DatagramHeader::decode stops at the end of the header and never owns the datagram’s tail, so the only layer that holds both the status and the bytes after it is this one. Without the check the application is handed, say, an End-of-Group object carrying four bytes of payload — a combination the draft forbids outright.

Recoverable: the drafts state the rule as a property of a conforming object, not as one of the “MUST close the session” cases, so the datagram is refused and the session left running.

Fields

§object_id: u64

Object ID from the datagram header.

§payload_len: usize

How many bytes followed the header.

§status: Option<ObjectStatus>

The status the header declared.

Spelled out in full because the glob import of moqtap_codec::types brings a different ObjectStatus into this module.

§

PropertiesOnNonNormalStatus

An Object arrived carrying properties on a status that is not Normal.

Draft-23 Section 11.1.2: “Any Object with status Normal can have properties (Section 8.4). If an endpoint receives properties on an Object with status that is not Normal, it MUST close the session with INVALID_OBJECT_STATUS.”

The codec’s read_object refuses such an Object as a bare InvalidField. Its read_object_meta frames it, which is how the receive path names the rule here and stays in step with the wire.

Fields

§object_id: u64

The Object ID the properties arrived on.

§properties_len: usize

Length in bytes of the properties block.

§status: ObjectStatus

The Object’s status, resolved through the encoding’s elision rule.

Spelled out in full because the glob import of moqtap_codec::types brings a different ObjectStatus into this module.

§

NonRequestOnRequestStream(MessageType)

A bidirectional stream the peer opened began with a message type that does not open a request stream.

Draft-23 Section 6.3: “Bidirectional streams MUST NOT begin with any other message type unless negotiated. If they do, the peer MUST close the Session with UNEXPECTED_MESSAGE.” The session has already been closed on the wire by the time this is returned, and the offending stream reset.

§

RespondedToOwnRequest(u64)

A respond_* helper was handed a request stream this endpoint opened. Nothing was written and no state moved.

§

FinBeforeResponse(u64)

RequestStream::finish was called on a request stream the peer opened before a response had been written on it. Nothing was written.

Draft-23 Section 6.4.2.2: “An endpoint MUST NOT send a FIN on a direction of a request stream until it has sent all required messages on that direction for its request type. In particular, an endpoint sending a response to a request MUST send the corresponding response message … before sending a FIN.”

§

FinBeforePublishDone(u64)

RequestStream::finish was called on a subscription this endpoint is the publisher of, before PUBLISH_DONE. Nothing was written.

The second half of the same sentence in draft-23 Section 6.4.2.2: “the publisher of an Established subscription MUST send PUBLISH_DONE, before sending a FIN.” It applies to the accepted SUBSCRIBE a responder answered with SUBSCRIBE_OK and to the PUBLISH this endpoint sent, which is why Connection::publish_done and Connection::publish_done_on are the only routes that clear it.

Trait Implementations§

Source§

impl Debug for ConnectionError

Source§

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

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

impl Display for ConnectionError

Source§

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

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

impl Error for ConnectionError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<CodecError> for ConnectionError

Source§

fn from(source: CodecError) -> Self

Converts to this type from the input type.
Source§

impl From<ConnectionError> for AnyConnectionError

Available on crate feature draft23 only.
Source§

fn from(err: ConnectionError) -> Self

Converts to this type from the input type.
Source§

impl From<DialError> for ConnectionError

Source§

fn from(e: DialError) -> Self

Maps a dial failure onto the variants this error already has, so a caller matches InvalidAddress or TlsConfig.

A LocalSocket failure maps to InvalidAddress, which the facade reads as this side’s failure (ErrorCause::Facade). The dial phase stays on DialError::phase.

Source§

impl From<EndpointError> for ConnectionError

Source§

fn from(source: EndpointError) -> Self

Converts to this type from the input type.
Source§

impl From<TransportError> for ConnectionError

Source§

fn from(source: TransportError) -> Self

Converts to this type from the input type.
Source§

impl From<VarIntError> for ConnectionError

Source§

fn from(source: VarIntError) -> Self

Converts to this type from the input type.

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