polyoxide_binance/lib.rs
1//! # polyoxide-binance
2//!
3//! Rust client library for Binance's APIs, one feature per module: `usdm` and `spot`.
4//!
5//! `usdm` (feature `usdm`, on by default) reads USDⓈ-M futures public market
6//! data (`fapi.binance.com`), and with `usdm-ws` its market streams
7//! (`fstream.binance.com`). `spot` (feature `spot`, on by default) reads spot
8//! public market data (`api.binance.com`), and with `spot-ws` its market
9//! streams (`stream.binance.com`). No credentials are needed. Each module's
10//! own docs carry its example.
11
12// Compile the crate README's `rust` code fences as doctests so broken examples
13// fail CI. `doctest` keeps this out of normal builds and `cargo doc`.
14#[cfg(all(doctest, feature = "usdm"))]
15#[doc = include_str!("../README.md")]
16struct ReadmeDoctests;
17
18// Each module's README is a doctest under its own feature, as the crate's is.
19// `.github/scripts/tests/test_module_readmes.py` fails when a module README
20// has no include here, or an include names no README.
21#[cfg(all(doctest, feature = "usdm"))]
22#[doc = include_str!("usdm/README.md")]
23struct UsdmReadmeDoctests;
24
25#[cfg(all(doctest, feature = "spot"))]
26#[doc = include_str!("spot/README.md")]
27struct SpotReadmeDoctests;
28
29#[cfg(any(feature = "usdm", feature = "spot"))]
30mod shared;
31
32#[cfg(feature = "usdm")]
33pub mod usdm;
34
35#[cfg(feature = "spot")]
36pub mod spot;
37
38// Every public error type implements `Classify`; one without it fails the
39// build here. `.github/scripts/tests/test_classify_coverage.py` fails when a
40// public error type is missing from this list.
41#[cfg(feature = "usdm")]
42const _: fn() = || {
43 fn is<T: polyoxide_venue::Classify>() {}
44 is::<usdm::UsdmError>();
45 is::<usdm::types::InvalidSymbol>();
46 #[cfg(feature = "usdm-ws")]
47 is::<usdm::ws::UsdmWsError>();
48 #[cfg(feature = "usdm-ws")]
49 is::<usdm::ws::InvalidStreamName>();
50};
51
52// The spot module's error types, in the same assertion `usdm`'s are in.
53#[cfg(feature = "spot")]
54const _: fn() = || {
55 fn is<T: polyoxide_venue::Classify>() {}
56 is::<spot::SpotError>();
57 is::<spot::types::InvalidSymbol>();
58 #[cfg(feature = "spot-ws")]
59 is::<spot::ws::SpotWsError>();
60 #[cfg(feature = "spot-ws")]
61 is::<spot::ws::InvalidStreamName>();
62};
63
64// Every product implements its class's bundle; one that drops a defining
65// capability fails the build here.
66#[cfg(feature = "usdm")]
67const _: fn() = || {
68 fn bundle<T: polyoxide_venue::PerpetualMarket>() {}
69 bundle::<usdm::Usdm>();
70};
71
72#[cfg(feature = "spot")]
73const _: fn() = || {
74 fn bundle<T: polyoxide_venue::SpotMarket>() {}
75 bundle::<spot::Spot>();
76};