#[non_exhaustive]pub enum Error {
Show 15 variants
UnsupportedExchange(String),
InvalidSymbol(String),
InvalidCredentials(&'static str),
InvalidOrder(&'static str),
Filter(String),
Auth(String),
InsufficientBalance,
RateLimited {
retry_after: Option<Duration>,
},
OrderRejected {
code: String,
message: String,
},
Exchange {
code: String,
message: String,
},
NotFound(String),
Timeout,
NotConnected,
Network(String),
Deserialization(String),
}Expand description
A unified connectivity / execution error.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnsupportedExchange(String)
No exchange is registered under the given name.
InvalidSymbol(String)
A symbol string could not be parsed or is not listed on the venue.
InvalidCredentials(&'static str)
Credentials are missing a field the venue requires (e.g. a passphrase).
InvalidOrder(&'static str)
An order request is malformed before it is ever sent.
Filter(String)
An order would violate one of the venue’s symbol filters (lot size, price tick, min-notional, …).
Auth(String)
Request signing or authentication was rejected by the venue.
InsufficientBalance
The account has insufficient balance for the request.
RateLimited
The venue rate-limited the request; retry_after is the advised wait if
the venue supplied one (Retry-After).
OrderRejected
The venue rejected the order after it was accepted for processing.
Fields
Exchange
Any other error reported by the venue, kept verbatim for diagnostics.
Fields
NotFound(String)
A requested entity (order, symbol metadata, …) was not found.
Timeout
The request timed out before a response was received.
NotConnected
A stream or client operation was attempted before connecting.
Network(String)
A transport-level (socket/TLS/DNS) failure.
Deserialization(String)
A response could not be parsed into the expected shape.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether retrying the operation could plausibly succeed: transient
transport failures, timeouts and rate limits. Permanent failures
(invalid order, auth, insufficient balance, …) return false.
Sourcepub fn code(&self) -> Option<&str>
pub fn code(&self) -> Option<&str>
The venue-supplied error code, if this error originated at an exchange.
Sourcepub fn with_retry_after(self, retry_after: Option<Duration>) -> Error
pub fn with_retry_after(self, retry_after: Option<Duration>) -> Error
Attach the venue’s advised wait to a rate-limit error that was raised without one.
The venue clients recognise a rate limit from the body – a numeric
code in the error envelope – while the wait arrives in the
Retry-After header. The two are read in different places, so this
joins them at the call site that has both.
Every other variant is returned untouched, and a RateLimited that
already carries a wait keeps it: a venue that states the delay in its
body is more specific than the header, and this must not overwrite it.
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · 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
use the Display impl or to_string()
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more