1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Live state kept from the websocket, sans-IO: markets, accounts, and the subscriptions that serve them.
//!
//! ```
//! use df_hyperliquid_core::utils::Dec;
//! use df_hyperliquid_core::client::Network;
//! use df_hyperliquid_core::live::store::{Interest, Store};
//! use df_hyperliquid_core::live::Session;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut store = Store::new(Network::Mainnet);
//! let mut session = Session::new(Network::Mainnet);
//! let book = store.register(Interest::Book { coin: "BTC".to_owned() })?;
//! store.sync(&mut session)?;
//! // The socket opens: the session subscribes to everything the store asked for.
//! let to_send = session.opened(0);
//! assert_eq!(to_send.len(), 1);
//!
//! let text = r#"{"channel":"l2Book","data":{"coin":"BTC","time":1,"levels":[[{"px":"100","sz":"1","n":1}],[{"px":"101","sz":"2","n":1}]]}}"#;
//! let frame = session.received(1_000, text)?;
//! store.apply(1_000, &frame);
//! assert_eq!(store.mid("BTC"), Some(Dec::parse("100.5")?));
//! assert_eq!(store.book("BTC").map(|book| book.age(4_000)), Some(3_000));
//!
//! // Dropping the handle drops the book, and the next sync unsubscribes it.
//! drop(book);
//! assert_eq!(store.sync(&mut session)?.frames.len(), 1);
//! assert!(store.book("BTC").is_none());
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
pub use ;
pub use Stamped;
pub use ;