#[non_exhaustive]pub enum BinanceError {
Api(ApiError),
Venue {
status: u16,
code: i64,
msg: String,
},
RateLimited {
retry_after: Option<Duration>,
},
IpBanned {
retry_after: Option<Duration>,
},
RegionBlocked {
msg: String,
},
Forbidden {
msg: String,
},
}Expand description
Error type for Binance API operations.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Api(ApiError)
Transport, decoding, or an error body in a shape Binance does not use.
Venue
Binance refused the request with its {"code", "msg"} body: an unknown
symbol is 400 with code -1121.
Fields
RateLimited
Still answered 429 after the retry schedule ran out.
IpBanned
418: Binance has banned this IP for continuing after a 429. Every
request on the same WeightBudget waits until the
ban lifts.
Fields
RegionBlocked
451: Binance does not serve the caller’s location.
Forbidden
403: Binance’s web application firewall refused the request.
Implementations§
Source§impl BinanceError
impl BinanceError
Sourcepub fn is_retriable(&self) -> bool
pub fn is_retriable(&self) -> bool
Whether re-sending the same request could plausibly succeed.
A 429, and a 408, 425 or 5xx however its body is shaped, are, as
core’s ApiError::is_retriable says for those statuses. A ban, a region
block and a firewall refusal are not: sending again does not change
them, and sending after a 418 lengthens the ban.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
The Retry-After delay, for a 429 or a 418 that carried one.
Trait Implementations§
Source§impl Debug for BinanceError
impl Debug for BinanceError
Source§impl Display for BinanceError
impl Display for BinanceError
Source§impl Error for BinanceError
impl Error for BinanceError
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()
Source§impl From<ApiError> for BinanceError
impl From<ApiError> for BinanceError
Source§impl From<Error> for BinanceError
impl From<Error> for BinanceError
Source§impl From<ParseError> for BinanceError
impl From<ParseError> for BinanceError
Source§fn from(err: ParseError) -> Self
fn from(err: ParseError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for BinanceError
impl !UnwindSafe for BinanceError
impl Freeze for BinanceError
impl Send for BinanceError
impl Sync for BinanceError
impl Unpin for BinanceError
impl UnsafeUnpin for BinanceError
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.