pub struct BybitAuth { /* private fields */ }Expand description
Bybit V5 authentication implementation
Implementations§
Source§impl BybitAuth
impl BybitAuth
Sourcepub const fn new(api_key: SmartString, secret_key: SmartString) -> Self
pub const fn new(api_key: SmartString, secret_key: SmartString) -> Self
Create new Bybit V5 auth instance
Sourcepub const fn with_recv_window(
api_key: SmartString,
secret_key: SmartString,
recv_window: u64,
) -> Self
pub const fn with_recv_window( api_key: SmartString, secret_key: SmartString, recv_window: u64, ) -> Self
Create new Bybit V5 auth instance with custom receive window
Sourcepub fn get_timestamp() -> u64
pub fn get_timestamp() -> u64
Get current timestamp in milliseconds
Sourcepub fn generate_rest_signature(
&self,
timestamp: u64,
params: &str,
) -> Result<SmartString>
pub fn generate_rest_signature( &self, timestamp: u64, params: &str, ) -> Result<SmartString>
Generate signature for REST API requests Format: timestamp + api_key + recv_window + params
Sourcepub fn generate_ws_signature(&self, expires: u64) -> Result<SmartString>
pub fn generate_ws_signature(&self, expires: u64) -> Result<SmartString>
Generate signature for WebSocket authentication Format: GET/realtime{expires}
Sourcepub fn create_rest_headers(
&self,
timestamp: u64,
params: &str,
) -> Result<FxHashMap<SmartString, SmartString>>
pub fn create_rest_headers( &self, timestamp: u64, params: &str, ) -> Result<FxHashMap<SmartString, SmartString>>
Create REST API headers for authenticated requests
Sourcepub fn create_ws_auth_message(
&self,
req_id: Option<SmartString>,
) -> Result<BybitWsAuthMessage>
pub fn create_ws_auth_message( &self, req_id: Option<SmartString>, ) -> Result<BybitWsAuthMessage>
Create WebSocket authentication message
Sourcepub fn create_ws_trading_header(&self, timestamp: u64) -> BybitWsMessageHeader
pub fn create_ws_trading_header(&self, timestamp: u64) -> BybitWsMessageHeader
Create WebSocket trading message header
Sourcepub fn create_ws_trading_message(
&self,
req_id: SmartString,
operation: SmartString,
args: Vec<OwnedValue>,
) -> BybitWsTradingMessage
pub fn create_ws_trading_message( &self, req_id: SmartString, operation: SmartString, args: Vec<OwnedValue>, ) -> BybitWsTradingMessage
Create WebSocket trading message
Sourcepub fn is_timestamp_valid(&self, timestamp: u64) -> bool
pub fn is_timestamp_valid(&self, timestamp: u64) -> bool
Validate timestamp to prevent replay attacks
Sourcepub const fn api_key(&self) -> &SmartString
pub const fn api_key(&self) -> &SmartString
Get API key for external use
Sourcepub const fn recv_window(&self) -> u64
pub const fn recv_window(&self) -> u64
Get receive window for external use
Sourcepub fn generate_headers(
&self,
method: &str,
path: &str,
body: Option<&str>,
) -> Result<FxHashMap<SmartString, SmartString>>
pub fn generate_headers( &self, method: &str, path: &str, body: Option<&str>, ) -> Result<FxHashMap<SmartString, SmartString>>
Generate headers for REST API requests (compatibility method)
This method provides compatibility with the expected signature for exchange implementations. It generates a timestamp internally and creates the parameter string for signing.
For GET requests, query parameters from the path are used for signing. For POST/PUT/DELETE requests, the body is used for signing.