pub struct HttpClient { /* private fields */ }Expand description
HTTP client for making REST API requests to Bybit.
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new(config: ClientConfig) -> Result<Self, BybitError>
pub fn new(config: ClientConfig) -> Result<Self, BybitError>
Create a new HTTP client with the given configuration.
Sourcepub fn config(&self) -> &ClientConfig
pub fn config(&self) -> &ClientConfig
Get the client configuration.
Sourcepub fn time_offset(&self) -> i64
pub fn time_offset(&self) -> i64
Get the current time offset.
Sourcepub fn set_time_offset(&self, offset_ms: i64)
pub fn set_time_offset(&self, offset_ms: i64)
Set the time offset manually.
Sourcepub async fn get<T, P>(
&self,
endpoint: &str,
params: Option<&P>,
) -> Result<T, BybitError>
pub async fn get<T, P>( &self, endpoint: &str, params: Option<&P>, ) -> Result<T, BybitError>
Make a public (unauthenticated) GET request.
Sourcepub async fn get_signed<T, P>(
&self,
endpoint: &str,
params: Option<&P>,
) -> Result<T, BybitError>
pub async fn get_signed<T, P>( &self, endpoint: &str, params: Option<&P>, ) -> Result<T, BybitError>
Make a private (authenticated) GET request.
Sourcepub async fn post_signed<T, B>(
&self,
endpoint: &str,
body: Option<&B>,
) -> Result<T, BybitError>
pub async fn post_signed<T, B>( &self, endpoint: &str, body: Option<&B>, ) -> Result<T, BybitError>
Make a private (authenticated) POST request.
Sourcepub async fn sync_time(&self) -> Result<i64, BybitError>
pub async fn sync_time(&self) -> Result<i64, BybitError>
Synchronize time with the server.
This fetches the server time and calculates the offset between local time and server time. The offset is used to adjust timestamps in authenticated requests.
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Auto Trait Implementations§
impl !Freeze for HttpClient
impl !RefUnwindSafe for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl !UnwindSafe for HttpClient
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
Mutably borrows from an owned value. Read more