#[non_exhaustive]pub enum BinanceWsError {
MissingStream {
raw: String,
},
UnsupportedEvent {
event: String,
},
SubscriptionFailed {
stream: String,
reason: String,
},
Connection(String),
Core(Error),
}Expand description
Binance WebSocket specific errors.
Implements StdError + Send + Sync for use with CoreError::WebSocket.
Uses #[non_exhaustive] to allow adding variants in future versions.
§Variants
MissingStream: Stream name missing in WebSocket messageUnsupportedEvent: Received an unsupported event typeSubscriptionFailed: Stream subscription failedConnection: WebSocket connection errorCore: Passthrough for core errors
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
MissingStream
Stream name missing in message.
This occurs when a WebSocket message doesn’t contain the expected stream identifier, making it impossible to route the message.
UnsupportedEvent
Unsupported event type.
This occurs when the WebSocket receives an event type that is not handled by the current implementation.
SubscriptionFailed
Subscription failed.
This occurs when a stream subscription request is rejected by the Binance WebSocket server.
Fields
Connection(String)
WebSocket connection error.
General connection-related errors that don’t fit other categories.
Core(Error)
Core error passthrough.
Allows wrapping core errors within Binance-specific error handling while maintaining the ability to extract the original error.
Implementations§
Source§impl BinanceWsError
impl BinanceWsError
Sourcepub fn missing_stream(raw: impl Into<String>) -> Self
pub fn missing_stream(raw: impl Into<String>) -> Self
Sourcepub fn unsupported_event(event: impl Into<String>) -> Self
pub fn unsupported_event(event: impl Into<String>) -> Self
Sourcepub fn connection(message: impl Into<String>) -> Self
pub fn connection(message: impl Into<String>) -> Self
Sourcepub fn stream_name(&self) -> Option<&str>
pub fn stream_name(&self) -> Option<&str>
Returns the stream name if this error is related to a specific stream.
§Returns
Some(&str)- The stream name forSubscriptionFailedvariantNone- For all other variants
§Example
use ccxt_exchanges::binance::error::BinanceWsError;
let err = BinanceWsError::subscription_failed("btcusdt@ticker", "Invalid");
assert_eq!(err.stream_name(), Some("btcusdt@ticker"));
let err = BinanceWsError::connection("Failed");
assert_eq!(err.stream_name(), None);Sourcepub fn event_type(&self) -> Option<&str>
pub fn event_type(&self) -> Option<&str>
Returns the event type if this is an UnsupportedEvent error.
§Returns
Some(&str)- The event type forUnsupportedEventvariantNone- For all other variants
Sourcepub fn raw_message(&self) -> Option<&str>
pub fn raw_message(&self) -> Option<&str>
Returns the raw message if this is a MissingStream error.
§Returns
Some(&str)- The raw message forMissingStreamvariantNone- For all other variants
Trait Implementations§
Source§impl Debug for BinanceWsError
impl Debug for BinanceWsError
Source§impl Display for BinanceWsError
impl Display for BinanceWsError
Source§impl Error for BinanceWsError
impl Error for BinanceWsError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<BinanceWsError> for Error
Conversion from BinanceWsError to CoreError.
impl From<BinanceWsError> for Error
Conversion from BinanceWsError to CoreError.
This implementation allows Binance-specific errors to be returned from
public API methods that return CoreError. The conversion preserves
the original error for downcast capability.
§Conversion Rules
BinanceWsError::Core(core)→ Returns the innerCoreErrordirectly- All other variants → Boxed into
CoreError::WebSocketfor downcast
Source§fn from(e: BinanceWsError) -> Self
fn from(e: BinanceWsError) -> Self
Auto Trait Implementations§
impl Freeze for BinanceWsError
impl !RefUnwindSafe for BinanceWsError
impl Send for BinanceWsError
impl Sync for BinanceWsError
impl Unpin for BinanceWsError
impl !UnwindSafe for BinanceWsError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.