pub enum BybitError {
Retryable {
source: BybitRetryableError,
retry_after: Option<Duration>,
},
NonRetryable {
source: BybitNonRetryableError,
},
Fatal {
source: BybitFatalError,
},
Network(HttpClientError),
WebSocket(String),
Json {
message: String,
raw: Option<String>,
},
Config(String),
}Expand description
The main error type for all Bybit adapter operations.
Variants§
Retryable
Errors that should be retried with backoff.
Fields
source: BybitRetryableErrorNonRetryable
Errors that should not be retried.
Fields
source: BybitNonRetryableErrorFatal
Fatal errors that require intervention.
Fields
source: BybitFatalErrorNetwork(HttpClientError)
Network transport errors.
WebSocket(String)
WebSocket specific errors.
Json
JSON serialization/deserialization errors.
Config(String)
Configuration errors.
Implementations§
Source§impl BybitError
impl BybitError
Sourcepub fn from_rate_limit_headers(
limit_status: Option<&str>,
limit: Option<&str>,
reset_timestamp: Option<&str>,
) -> Self
pub fn from_rate_limit_headers( limit_status: Option<&str>, limit: Option<&str>, reset_timestamp: Option<&str>, ) -> Self
Creates a new rate limit error from HTTP headers.
Bybit uses the following headers:
- X-Bapi-Limit: Rate limit window
- X-Bapi-Limit-Status: Current usage
- X-Bapi-Limit-Reset-Timestamp: Reset time (Unix timestamp in ms)
§Parameters
limit_status: X-Bapi-Limit-Status header value (e.g., “148”)limit: X-Bapi-Limit header value (e.g., “150”)reset_timestamp: X-Bapi-Limit-Reset-Timestamp header value (Unix ms)
Sourcepub fn from_http_status(status: u16, message: Option<String>) -> Self
pub fn from_http_status(status: u16, message: Option<String>) -> Self
Creates an error from an HTTP status code and optional message.
Sourcepub fn from_http_response(response: &HttpResponse) -> Self
pub fn from_http_response(response: &HttpResponse) -> Self
Creates an error from an HTTP response.
Sourcepub fn from_bybit_ret_code(ret_code: i32, message: String) -> Self
pub fn from_bybit_ret_code(ret_code: i32, message: String) -> Self
Creates an error from a Bybit API response with retCode.
Bybit returns errors with retCode and retMsg fields. See https://bybit-exchange.github.io/docs/v5/error for error codes.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Checks if this error is retryable.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
Gets the suggested retry duration if available.
Trait Implementations§
Source§impl Debug for BybitError
impl Debug for BybitError
Source§impl Display for BybitError
impl Display for BybitError
Source§impl Error for BybitError
impl Error for BybitError
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<BybitHttpError> for BybitError
impl From<BybitHttpError> for BybitError
Source§fn from(error: BybitHttpError) -> Self
fn from(error: BybitHttpError) -> Self
Source§impl From<BybitWsError> for BybitError
impl From<BybitWsError> for BybitError
Source§fn from(error: BybitWsError) -> Self
fn from(error: BybitWsError) -> Self
Source§impl From<Error> for BybitError
impl From<Error> for BybitError
Source§impl From<Error> for BybitError
impl From<Error> for BybitError
Auto Trait Implementations§
impl Freeze for BybitError
impl RefUnwindSafe for BybitError
impl Send for BybitError
impl Sync for BybitError
impl Unpin for BybitError
impl UnwindSafe for BybitError
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Separable for Twhere
T: Display,
impl<T> Separable for Twhere
T: Display,
Source§fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
SeparatorPolicy. Read moreSource§fn separate_with_commas(&self) -> String
fn separate_with_commas(&self) -> String
Source§fn separate_with_spaces(&self) -> String
fn separate_with_spaces(&self) -> String
Source§fn separate_with_dots(&self) -> String
fn separate_with_dots(&self) -> String
Source§fn separate_with_underscores(&self) -> String
fn separate_with_underscores(&self) -> String
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.