Skip to main content

ErrorCode

Struct ErrorCode 

Source
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: i64

Implementations§

Source§

impl ErrorCode

Source

pub const fn new(code: i64) -> Self

Source

pub const fn raw(self) -> i64

Raw numeric code as returned by Binance.

Source§

impl ErrorCode

Source

pub const UNKNOWN: Self

Source

pub const DISCONNECTED: Self

Source

pub const UNAUTHORIZED: Self

Source

pub const TOO_MANY_REQUESTS: Self

Source

pub const UNEXPECTED_RESP: Self

Source

pub const TIMEOUT: Self

Source

pub const SERVER_BUSY: Self

Source

pub const TOO_MANY_ORDERS: Self

Source

pub const SERVICE_SHUTTING_DOWN: Self

Source

pub const UNSUPPORTED_OPERATION: Self

Source

pub const INVALID_TIMESTAMP: Self

Source

pub const INVALID_SIGNATURE: Self

Source

pub const TOO_MANY_CONNECTIONS: Self

Source

pub const ILLEGAL_CHARS: Self

Source

pub const TOO_MANY_PARAMETERS: Self

Source

pub const MANDATORY_PARAM_EMPTY_OR_MALFORMED: Self

Source

pub const UNKNOWN_PARAM: Self

Source

pub const BAD_SYMBOL: Self

Source

pub const INVALID_LISTEN_KEY: Self

Source

pub const TOO_MANY_MESSAGES: Self

Source

pub const TOO_MANY_SUBSCRIPTIONS: Self

Source

pub const NEW_ORDER_REJECTED: Self

Source

pub const CANCEL_REJECTED: Self

Source

pub const NO_SUCH_ORDER: Self

Source

pub const BAD_API_KEY_FMT: Self

Source

pub const REJECTED_MBX_KEY: Self

Source

pub const NO_TRADING_WINDOW: Self

Source

pub const ORDER_AMEND_REJECTED: Self

Source

pub const CLIENT_ORDER_ID_INVALID: Self

Source§

impl ErrorCode

Source

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

Source

pub fn is_invalid_timestamp(self) -> bool

Local clock drifted outside the server’s recvWindow. Re-sync time and retry. Code: INVALID_TIMESTAMP (-1021).

Source

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

Source

pub fn is_bad_api_key_format(self) -> bool

API key format is invalid (length / characters). Code: -2014.

Source

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.

Source

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.

Source

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.

Source

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

Source

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

Source

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.

Source

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

Source

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§

Source§

impl Clone for ErrorCode

Source§

fn clone(&self) -> ErrorCode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ErrorCode

Source§

impl Debug for ErrorCode

Source§

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

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

impl<'de> Deserialize<'de> for ErrorCode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ErrorCode

Source§

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

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

impl Eq for ErrorCode

Source§

impl From<ErrorCode> for i64

Source§

fn from(code: ErrorCode) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for ErrorCode

Source§

fn from(code: i64) -> Self

Converts to this type from the input type.
Source§

impl Hash for ErrorCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ErrorCode

Source§

fn eq(&self, other: &ErrorCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ErrorCode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ErrorCode

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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