Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error { Config(ConfigError), Session(ServerError), Request(ServerError), ReconnectExhausted { attempts: u32, last: Option<Box<DisconnectReason>>, }, Disconnected, Transport(TransportError), ForeignSubscription { id: u64, }, Internal { reason: String, }, }
Expand description

Anything that can go wrong in a Lightstreamer client.

The variants are grouped by what a caller can do about them:

§Which of these this crate returns, and which you construct

Everything above is returned by some call, except one: Error::Request is the way to propagate a refusal that arrived as an event. A refused control request is not the return value of anything — it reaches you as SessionEvent::RequestRejected or SubscriptionEvent::Rejected, because it happens long after the call that caused it returned. Wrapping the ServerError it carries in Error::Request is what lets an application hand it to ? alongside the errors this crate returns, and ClosedReason::into_error does the same for the session-level events.

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

Config(ConfigError)

A configuration value could not be used as given. Nothing was sent to any server.

§

Session(ServerError)

The server refused to create or bind the session, or ended one that was running, with a code from Appendix A [docs/spec/05-error-codes.md §2].

This crate reached this error only after deciding the code admits no retry — for the codes the specification marks as temporary it keeps trying, and you learn about that through the session event stream instead.

§

Request(ServerError)

The server refused a control request — a subscription, an unsubscription, a reconfiguration or a message — with a code from Appendix B [docs/spec/05-error-codes.md §2].

The session itself is unaffected and remains usable.

§

ReconnectExhausted

The connection kept failing and the reconnection budget ran out. The session is definitively lost and this client will not try again.

The budget is RetryPolicy; raise it, or set it to unlimited, if giving up is not what you want.

Fields

§attempts: u32

How many consecutive attempts failed.

§last: Option<Box<DisconnectReason>>

Why the last attempt failed, when there was one to report.

Kept because the count on its own is not diagnosable: “eight attempts failed” is the same sentence whether the credentials were refused, the host did not resolve, or the connection kept going silent. Boxed only to keep Error small.

§

Disconnected

The client is no longer connected, because it was disconnected or dropped.

Not a failure in itself: it is what every pending operation returns once the session has stopped.

§

Transport(TransportError)

Something went wrong moving bytes — connecting, sending, or receiving.

§

ForeignSubscription

A SubscriptionId created by a different client was passed to Client::unsubscribe.

Nothing was sent. Each client numbers its subscriptions from one, so the same number names a different subscription on each of them; acting on it would have cancelled somebody else’s data.

Fields

§id: u64

The number the handle carried, as SubscriptionId::get reports it.

§

Internal

This crate could not do something it should always be able to do.

A bug, never a server condition or a configuration mistake.

Fields

§reason: String

What failed. Never contains a credential.

Implementations§

Source§

impl Error

Source

pub const fn server_error(&self) -> Option<&ServerError>

The server’s code and message, when the server supplied one.

A convenience for the common “log the code, then decide” shape. Use the variant itself when you need to know which catalog the code came from.

§Examples
use lightstreamer_rs::{Error, ServerError};

let error = Error::Request(ServerError::new(19, "Specified subscription not found"));
assert_eq!(error.server_error().map(ServerError::code), Some(19));

assert!(Error::Disconnected.server_error().is_none());
Source

pub const fn is_session_terminal(&self) -> bool

Whether the session behind this error is gone for good.

True for a server-side refusal, an exhausted reconnection budget and a disconnected client; false for a rejected control request, which leaves the session running, and for a configuration mistake, which never reached a server.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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

Source§

fn from(source: ConfigError) -> Self

Converts to this type from the input type.
Source§

impl From<TransportError> for Error

Source§

fn from(source: TransportError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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