Skip to main content

UsdmWsError

Enum UsdmWsError 

Source
#[non_exhaustive]
pub enum UsdmWsError { Connect(WsError), ConnectTimeout(Duration), Closed { code: Option<u16>, reason: String, }, Refused { code: i64, msg: String, }, NoAnswer { id: u64, timeout: Duration, }, Response { id: u64, raw: String, }, TooManyStreams { path: StreamPath, limit: usize, }, WrongPath { stream: StreamName, path: StreamPath, }, Frame { stream: String, raw: String, reason: String, }, Stopped { cause: Option<StopCause>, }, }
Expand description

Error type for the socket tiers.

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(WsError)

The connection could not be opened, or failed mid-stream: the kit’s one socket error, read through its Kind. A server close and a connect timeout have variants of their own.

§

ConnectTimeout(Duration)

The connection did not open within the connect timeout.

§

Closed

The server closed the connection, with its close code and reason when it sent them: 1008 "Too many requests" after a burst of requests, 1008 "Invalid request" after a refused 1025th stream.

Fields

§code: Option<u16>

The close code.

§reason: String

The close reason.

§

Refused

The server answered a request with {"error": {"code", "msg"}}.

Fields

§code: i64

Binance’s code.

§msg: String

Binance’s message.

§

NoAnswer

No answer to a request, or no pong to a ping (id 0), within the answer timeout.

Fields

§id: u64

The request id.

§timeout: Duration

How long the client waited.

§

Response

An answer that was not the documented shape.

Fields

§id: u64

The request id.

§raw: String

The answer as sent.

§

TooManyStreams

A subscribe that would take a connection past Binance’s cap. Nothing was sent: the server answers the 1025th stream with an error and then closes the connection, losing all 1024.

Fields

§path: StreamPath

The path whose connection is full.

§limit: usize

The cap.

§

WrongPath

A stream for the other path, on the bare tier. Nothing was sent.

Fields

§stream: StreamName

The stream.

§path: StreamPath

The connection’s path.

§

Frame

A text frame that did not decode as an update.

Fields

§stream: String

The envelope’s stream name, or empty when there was none.

§raw: String

The frame as sent.

§reason: String

Why it did not decode.

§

Stopped

The supervised tier has stopped; its handles can no longer be used.

cause is the error a path stopped on, as Classify read it, so a stream stopped by a reconnect refused with 451 is classed and tagged as that refusal is. None when the client stopped for another reason, such as a task that panicked, or before the stop’s cause was known.

Fields

§cause: Option<StopCause>

The error a path stopped on.

Trait Implementations§

Source§

impl Classify for UsdmWsError

The transport by the one socket table (polyoxide_venue::impl_ws_classification!), a server close by its close code, a refused request a VenueRefusal with Binance’s code in decimal, an answer or frame that did not parse a Decode, and the client’s own refusals an InvalidRequest.

One row is Binance’s own, ahead of the table (D14): a handshake refused with 403 is Restricted, as on REST. Binance’s firewall answers it, and it is not a credential failure, since the streams need none.

Every error is a fault except a handshake refused with 451: Binance does not serve the caller’s region, a defined outcome, as UsdmError::RegionBlocked is on REST. A 418 ban and a 403 from the firewall stay faults. A refused handshake’s Retry-After, of any status, is the error’s wait.

Stopped follows its cause, so a stop on a 451 refusal is Restricted and not a fault; one with no cause is an InvalidRequest and a fault.

Source§

fn class(&self) -> Class

The class of this error.
Source§

fn is_fault(&self) -> bool

Whether this error is a fault, rather than the venue answering as designed. False only for defined outcomes, such as a Fill-And-Kill order that matched nothing, or a venue that does not serve the caller’s region. Alerting should key on this; retrying should not.
Source§

fn retry_after(&self) -> Option<Duration>

How long the server asked the caller to wait. Defaults to the class’s own; an error whose wait outlives its class, such as a ban that says when it lifts, overrides it. Never Some of zero.
Source§

fn is_retriable(&self) -> bool

Whether retrying could plausibly succeed, read from the class (see Class::is_retriable).
Source§

impl Debug for UsdmWsError

Source§

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

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

impl Display for UsdmWsError

Source§

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

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

impl Error for UsdmWsError

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<WsError> for UsdmWsError

A server close is UsdmWsError::Closed, a connect timeout UsdmWsError::ConnectTimeout, and every other socket failure UsdmWsError::Connect.

Source§

fn from(err: WsError) -> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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