pub struct ErrorCode(pub i64);Expand description
Numeric Binance error code, as returned in the code field of an error
response body.
Kept as a newtype around i64 rather than a closed enum because Binance
adds new codes over time and product-specific endpoints use codes outside
the spot range. Use the named constants for the common ones and the
is_* predicates for category-based handling; fall back to
ErrorCode::raw for anything not classified.
Tuple Fields§
§0: i64Implementations§
Source§impl ErrorCode
impl ErrorCode
pub const UNKNOWN: Self
pub const DISCONNECTED: Self
pub const UNAUTHORIZED: Self
pub const TOO_MANY_REQUESTS: Self
pub const UNEXPECTED_RESP: Self
pub const TIMEOUT: Self
pub const SERVER_BUSY: Self
pub const TOO_MANY_ORDERS: Self
pub const SERVICE_SHUTTING_DOWN: Self
pub const UNSUPPORTED_OPERATION: Self
pub const INVALID_TIMESTAMP: Self
pub const INVALID_SIGNATURE: Self
pub const TOO_MANY_CONNECTIONS: Self
pub const ILLEGAL_CHARS: Self
pub const TOO_MANY_PARAMETERS: Self
pub const MANDATORY_PARAM_EMPTY_OR_MALFORMED: Self
pub const UNKNOWN_PARAM: Self
pub const BAD_SYMBOL: Self
pub const INVALID_LISTEN_KEY: Self
pub const TOO_MANY_MESSAGES: Self
pub const TOO_MANY_SUBSCRIPTIONS: Self
pub const NEW_ORDER_REJECTED: Self
pub const CANCEL_REJECTED: Self
pub const NO_SUCH_ORDER: Self
pub const BAD_API_KEY_FMT: Self
pub const REJECTED_MBX_KEY: Self
pub const NO_TRADING_WINDOW: Self
pub const ORDER_AMEND_REJECTED: Self
pub const CLIENT_ORDER_ID_INVALID: Self
Source§impl ErrorCode
impl ErrorCode
Sourcepub fn is_auth(self) -> bool
pub fn is_auth(self) -> bool
Authentication / signing failure. The request will not succeed without fixing the API key, signature or timestamp.
Covers: UNAUTHORIZED (-1002), INVALID_TIMESTAMP (-1021),
INVALID_SIGNATURE (-1022), BAD_API_KEY_FMT (-2014),
REJECTED_MBX_KEY (-2015).
Sourcepub fn is_invalid_timestamp(self) -> bool
pub fn is_invalid_timestamp(self) -> bool
Local clock drifted outside the server’s recvWindow. Re-sync time
and retry. Code: INVALID_TIMESTAMP (-1021).
Sourcepub fn is_invalid_signature(self) -> bool
pub fn is_invalid_signature(self) -> bool
HMAC signature doesn’t match. Usually a wrong API secret or a payload
that was modified after signing. Code: INVALID_SIGNATURE (-1022).
Sourcepub fn is_bad_api_key_format(self) -> bool
pub fn is_bad_api_key_format(self) -> bool
API key format is invalid (length / characters). Code: -2014.
Sourcepub fn is_api_key_rejected(self) -> bool
pub fn is_api_key_rejected(self) -> bool
API key was rejected because it’s been deleted/disabled, the source IP isn’t on its allowlist, or it lacks the permission this endpoint needs. Binance reports all three as code -2015.
Sourcepub fn is_wrong_permissions(self) -> bool
pub fn is_wrong_permissions(self) -> bool
The key lacks the permission required for this action. Same wire code
as Self::is_api_key_rejected (-2015); offered as a separate
predicate purely for caller intent.
Sourcepub fn is_bad_request(self) -> bool
pub fn is_bad_request(self) -> bool
Request was malformed — missing/extra parameter, bad value, bad symbol, etc. Range: -1199..=-1100.
Product-specific codes outside this range (e.g. futures -4001) are
not covered; use Self::raw to handle them.
Sourcepub fn is_rate_limited(self) -> bool
pub fn is_rate_limited(self) -> bool
Rate-limit / throughput error. Caller is sending too much.
Covers: TOO_MANY_REQUESTS (-1003), TOO_MANY_ORDERS (-1015),
TOO_MANY_CONNECTIONS (-1034), TOO_MANY_MESSAGES (-1181),
TOO_MANY_SUBSCRIPTIONS (-1191).
Sourcepub fn is_server_error(self) -> bool
pub fn is_server_error(self) -> bool
Server-side problem; the request itself may have been valid.
Covers: UNKNOWN (-1000), DISCONNECTED (-1001), UNEXPECTED_RESP
(-1006), TIMEOUT (-1007), SERVER_BUSY (-1008),
SERVICE_SHUTTING_DOWN (-1016).
Sourcepub fn is_transient(self) -> bool
pub fn is_transient(self) -> bool
Worth retrying — server-side or rate-limit. Auth / bad-request errors are not transient and will fail again on retry.
Sourcepub fn is_order_rejected(self) -> bool
pub fn is_order_rejected(self) -> bool
Matching engine rejected the order (filter / price / quantity rules, cancel-replace failure, amend rejected).
Covers: NEW_ORDER_REJECTED (-2010), CANCEL_REJECTED (-2011),
ORDER_AMEND_REJECTED (-2038).
Sourcepub fn is_no_such_order(self) -> bool
pub fn is_no_such_order(self) -> bool
The referenced order ID doesn’t exist (already filled/canceled or
never placed). Code: NO_SUCH_ORDER (-2013).
Trait Implementations§
impl Copy for ErrorCode
Source§impl<'de> Deserialize<'de> for ErrorCode
impl<'de> Deserialize<'de> for ErrorCode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ErrorCode
impl StructuralPartialEq for ErrorCode
Auto Trait Implementations§
impl Freeze for ErrorCode
impl RefUnwindSafe for ErrorCode
impl Send for ErrorCode
impl Sync for ErrorCode
impl Unpin for ErrorCode
impl UnsafeUnpin for ErrorCode
impl UnwindSafe for ErrorCode
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.