pub struct BinanceRawSpotHttpClient { /* private fields */ }Expand description
Low-level HTTP client for Binance Spot REST API with SBE encoding.
Handles:
- Base URL resolution by environment.
- Optional HMAC SHA256 signing for private endpoints.
- Rate limiting using Spot API quotas.
- SBE decoding to Binance-specific response types.
Methods are named to match Binance API endpoints and return venue-specific types (decoded from SBE).
Implementations§
Source§impl BinanceRawSpotHttpClient
impl BinanceRawSpotHttpClient
Sourcepub fn new(
environment: BinanceEnvironment,
api_key: Option<String>,
api_secret: Option<String>,
base_url_override: Option<String>,
recv_window: Option<u64>,
timeout_secs: Option<u64>,
proxy_url: Option<String>,
) -> BinanceSpotHttpResult<Self>
pub fn new( environment: BinanceEnvironment, api_key: Option<String>, api_secret: Option<String>, base_url_override: Option<String>, recv_window: Option<u64>, timeout_secs: Option<u64>, proxy_url: Option<String>, ) -> BinanceSpotHttpResult<Self>
Creates a new Binance Spot raw HTTP client.
§Errors
Returns an error if the underlying [HttpClient] fails to build.
Sourcepub const fn schema_version() -> u16
pub const fn schema_version() -> u16
Returns the SBE schema version.
Sourcepub async fn get<P>(
&self,
path: &str,
params: Option<&P>,
) -> BinanceSpotHttpResult<Vec<u8>>
pub async fn get<P>( &self, path: &str, params: Option<&P>, ) -> BinanceSpotHttpResult<Vec<u8>>
Performs a GET request and returns raw response bytes.
Sourcepub async fn get_signed<P>(
&self,
path: &str,
params: Option<&P>,
) -> BinanceSpotHttpResult<Vec<u8>>
pub async fn get_signed<P>( &self, path: &str, params: Option<&P>, ) -> BinanceSpotHttpResult<Vec<u8>>
Performs a signed GET request and returns raw response bytes.
Sourcepub async fn post_order<P>(
&self,
path: &str,
params: Option<&P>,
) -> BinanceSpotHttpResult<Vec<u8>>
pub async fn post_order<P>( &self, path: &str, params: Option<&P>, ) -> BinanceSpotHttpResult<Vec<u8>>
Performs a signed POST request for order operations.
Sourcepub async fn delete_order<P>(
&self,
path: &str,
params: Option<&P>,
) -> BinanceSpotHttpResult<Vec<u8>>
pub async fn delete_order<P>( &self, path: &str, params: Option<&P>, ) -> BinanceSpotHttpResult<Vec<u8>>
Performs a signed DELETE request for cancel operations.
Sourcepub async fn ping(&self) -> BinanceSpotHttpResult<()>
pub async fn ping(&self) -> BinanceSpotHttpResult<()>
Sourcepub async fn server_time(&self) -> BinanceSpotHttpResult<i64>
pub async fn server_time(&self) -> BinanceSpotHttpResult<i64>
Returns the server time in microseconds since epoch.
Note: SBE provides microsecond precision vs JSON’s milliseconds.
§Errors
Returns an error if the request fails or SBE decoding fails.
Sourcepub async fn exchange_info(
&self,
) -> BinanceSpotHttpResult<BinanceExchangeInfoSbe>
pub async fn exchange_info( &self, ) -> BinanceSpotHttpResult<BinanceExchangeInfoSbe>
Returns exchange information including trading symbols.
§Errors
Returns an error if the request fails or SBE decoding fails.
Sourcepub async fn depth(
&self,
params: &DepthParams,
) -> BinanceSpotHttpResult<BinanceDepth>
pub async fn depth( &self, params: &DepthParams, ) -> BinanceSpotHttpResult<BinanceDepth>
Returns order book depth for a symbol.
§Errors
Returns an error if the request fails or SBE decoding fails.
Sourcepub async fn trades(
&self,
params: &TradesParams,
) -> BinanceSpotHttpResult<BinanceTrades>
pub async fn trades( &self, params: &TradesParams, ) -> BinanceSpotHttpResult<BinanceTrades>
Returns recent trades for a symbol.
§Errors
Returns an error if the request fails or SBE decoding fails.
Sourcepub async fn new_order(
&self,
params: &NewOrderParams,
) -> BinanceSpotHttpResult<BinanceNewOrderResponse>
pub async fn new_order( &self, params: &NewOrderParams, ) -> BinanceSpotHttpResult<BinanceNewOrderResponse>
Sourcepub async fn cancel_order(
&self,
params: &CancelOrderParams,
) -> BinanceSpotHttpResult<BinanceCancelOrderResponse>
pub async fn cancel_order( &self, params: &CancelOrderParams, ) -> BinanceSpotHttpResult<BinanceCancelOrderResponse>
Sourcepub async fn cancel_open_orders(
&self,
params: &CancelOpenOrdersParams,
) -> BinanceSpotHttpResult<Vec<BinanceCancelOrderResponse>>
pub async fn cancel_open_orders( &self, params: &CancelOpenOrdersParams, ) -> BinanceSpotHttpResult<Vec<BinanceCancelOrderResponse>>
Cancels all open orders for a symbol.
§Errors
Returns an error if the request fails or SBE decoding fails.
Sourcepub async fn cancel_replace_order(
&self,
params: &CancelReplaceOrderParams,
) -> BinanceSpotHttpResult<BinanceNewOrderResponse>
pub async fn cancel_replace_order( &self, params: &CancelReplaceOrderParams, ) -> BinanceSpotHttpResult<BinanceNewOrderResponse>
Cancels an existing order and places a new order atomically.
§Errors
Returns an error if the request fails or SBE decoding fails.
Sourcepub async fn query_order(
&self,
params: &QueryOrderParams,
) -> BinanceSpotHttpResult<BinanceOrderResponse>
pub async fn query_order( &self, params: &QueryOrderParams, ) -> BinanceSpotHttpResult<BinanceOrderResponse>
Sourcepub async fn open_orders(
&self,
params: &OpenOrdersParams,
) -> BinanceSpotHttpResult<Vec<BinanceOrderResponse>>
pub async fn open_orders( &self, params: &OpenOrdersParams, ) -> BinanceSpotHttpResult<Vec<BinanceOrderResponse>>
Returns all open orders for a symbol or all symbols.
§Errors
Returns an error if the request fails or SBE decoding fails.
Sourcepub async fn all_orders(
&self,
params: &AllOrdersParams,
) -> BinanceSpotHttpResult<Vec<BinanceOrderResponse>>
pub async fn all_orders( &self, params: &AllOrdersParams, ) -> BinanceSpotHttpResult<Vec<BinanceOrderResponse>>
Returns all orders (including closed) for a symbol.
§Errors
Returns an error if the request fails or SBE decoding fails.
Sourcepub async fn account(
&self,
params: &AccountInfoParams,
) -> BinanceSpotHttpResult<BinanceAccountInfo>
pub async fn account( &self, params: &AccountInfoParams, ) -> BinanceSpotHttpResult<BinanceAccountInfo>
Returns account information including balances.
§Errors
Returns an error if the request fails or SBE decoding fails.
Sourcepub async fn account_trades(
&self,
params: &AccountTradesParams,
) -> BinanceSpotHttpResult<Vec<BinanceAccountTrade>>
pub async fn account_trades( &self, params: &AccountTradesParams, ) -> BinanceSpotHttpResult<Vec<BinanceAccountTrade>>
Returns account trade history for a symbol.
§Errors
Returns an error if the request fails or SBE decoding fails.
Trait Implementations§
Source§impl Clone for BinanceRawSpotHttpClient
impl Clone for BinanceRawSpotHttpClient
Source§fn clone(&self) -> BinanceRawSpotHttpClient
fn clone(&self) -> BinanceRawSpotHttpClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BinanceRawSpotHttpClient
impl !RefUnwindSafe for BinanceRawSpotHttpClient
impl Send for BinanceRawSpotHttpClient
impl Sync for BinanceRawSpotHttpClient
impl Unpin for BinanceRawSpotHttpClient
impl !UnwindSafe for BinanceRawSpotHttpClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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