Skip to main content

TransportError

Enum TransportError 

Source
#[non_exhaustive]
pub enum TransportError { Connect { target: String, source: Box<dyn Error + Send + Sync>, }, ConnectionLost { reason: String, }, Send { name: &'static str, reason: String, }, MalformedFrame { reason: String, }, Capacity { limit_bytes: usize, reason: String, }, }
Expand description

Something went wrong moving bytes. Carries no protocol meaning.

This type belongs to the public taxonomy, not to a transport. It is defined here, beside Error, because the distinction it draws is one a caller can act on — failing to connect and losing an established stream call for different responses — and because a type in this crate’s semver promise must be owned by the module that makes that promise. The transports themselves stay private and merely produce these; adding one is not a semver event (docs/adr/0007-transport-port-shape.md), and it must not become one by an adapter widening this enum on its own account.

§On the cause of TransportError::Connect

It is a Box<dyn Error> rather than a named type so that no dependency’s semantic version becomes part of this crate’s. Read it, log it, print its chain — but do not downcast it: which concrete error arrives there depends on which transport ran and on the version of the crate underneath it, and neither is part of the promise made here. Everything worth branching on is the variant.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Connect

The connection could not be established.

Fields

§target: String

What was being connected to. Never carries userinfo: an address with a user:password@ prefix is refused at configuration time, and what reaches here is redacted regardless.

§source: Box<dyn Error + Send + Sync>

The underlying failure. Opaque by design — see the type docs.

§

ConnectionLost

The connection failed or was dropped while in use.

This is transition T5 [docs/spec/02-session-lifecycle.md §2.2]: no notification is received, the session is not closed, and the client is still entitled to attempt recovery.

Fields

§reason: String

What ended it.

§

Send

A control request could not be delivered.

Fields

§name: &'static str

The request name, as TLCP spells it — control, msg, heartbeat [docs/spec/03-requests.md §1].

§reason: String

What went wrong.

§

MalformedFrame

The peer sent a frame that cannot be turned into TLCP lines — a binary WebSocket message, or bytes that are not valid UTF-8.

Fields

§reason: String

What was wrong with it.

§

Capacity

The peer sent more than this client is willing to buffer for it.

Every dimension a server controls is capped, because a client that allocates whatever it is told to is one malformed stream away from taking its process with it. The connection is not usable afterwards: what was buffered has been discarded, so the line stream has a hole in it and the session must be recovered rather than resumed.

Fields

§limit_bytes: usize

The ceiling that was exceeded.

§reason: String

What exceeded it. Never contains a credential.

Trait Implementations§

Source§

impl Debug for TransportError

Source§

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

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

impl Display for TransportError

Source§

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

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

impl Error for TransportError

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<TransportError> for Error

Source§

fn from(source: TransportError) -> 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.

Source§

impl<T> Instrument for T

Source§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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