|
Binance C++ Connector 2.0.0
Official C++ connectors for the Binance APIs
|
The REST transport shared by every product. More...
#include <rest.hpp>
Public Types | |
| using | Signature = void(std::exception_ptr, RawResponse) |
| using | Handler = boost::asio::any_completion_handler<Signature> |
Public Member Functions | |
| RestClient (RestApiConfig configuration, detail::ClientOptions options={}) | |
| Throws ConfigError if base_path or proxy is invalid, or ConnectorClientError if the private key cannot be loaded. | |
| ~RestClient () | |
| RestClient (const RestClient &)=delete | |
| RestClient & | operator= (const RestClient &)=delete |
| RestClient (RestClient &&)=delete | |
| RestClient & | operator= (RestClient &&)=delete |
| const RestApiConfig & | configuration () const noexcept |
| The configuration, as given but without private_key_passphrase (the key is loaded). | |
| const SignatureGenerator & | signature_generator () const noexcept |
| boost::asio::any_io_executor | get_executor () const noexcept |
| template<class CompletionToken> | |
| auto | async_send_request (RestRequest request, CompletionToken &&token) |
| Asynchronous send. | |
| RawResponse | send_request (RestRequest request) |
| Blocking send. | |
The REST transport shared by every product.
It runs on its own I/O thread, or on configuration.executor when set, and keeps a keep-alive connection pool. It handles signing, retries, gzip / deflate decoding, rate-limit headers and error mapping.
Completion handlers run on the handler's associated executor. Without one, they run on the client's executor (get_executor()). Errors are delivered as std::exception_ptr, which holds a ConnectorError subclass.
Without configuration.executor, the executor from get_executor() belongs to the client's own I/O context: neither it nor I/O objects created on it may outlive the client. Destruction waits for the I/O thread, which may be held up by a DNS lookup in progress (getaddrinfo cannot be interrupted).
| using binance::common::RestClient::Signature = void(std::exception_ptr, RawResponse) |
| using binance::common::RestClient::Handler = boost::asio::any_completion_handler<Signature> |
|
explicit |
Throws ConfigError if base_path or proxy is invalid, or ConnectorClientError if the private key cannot be loaded.
| binance::common::RestClient::~RestClient | ( | ) |
|
delete |
|
delete |
|
delete |
|
delete |
|
nodiscardnoexcept |
The configuration, as given but without private_key_passphrase (the key is loaded).
|
nodiscardnoexcept |
|
nodiscardnoexcept |
|
inline |
Asynchronous send.
token may be a callback void(std::exception_ptr, RawResponse), boost::asio::use_future, boost::asio::use_awaitable, …
Supports per-operation cancellation (bind_cancellation_slot, parallel groups, or cancel_after(timer, duration, token) with a timer on the caller's executor): the request then completes with RequestCancelledError, whose request_sent() says whether it may have reached the server. Terminal and partial cancellation are always honoured; total cancellation only until the request starts to be written, and is ignored after that. A response that has already arrived is delivered instead. Destroying the client cancels every in-flight request the same way.
| RawResponse binance::common::RestClient::send_request | ( | RestRequest | request | ) |
Blocking send.
Throws a ConnectorError subclass on failure. Must not be called from the client's executor, nor from a thread running a shared one.