ws_all_mids/
ws_all_mids.rs1use hyperliquid::{
2 types::{
3 websocket::{
4 request::{Channel, Subscription},
5 response::Response,
6 },
7 Chain,
8 },
9 Hyperliquid, Result, Websocket,
10};
11
12#[tokio::main]
13async fn main() -> Result<()> {
14 let mut ws: Websocket = Hyperliquid::new(Chain::Dev);
15
16 ws.connect().await?;
17
18 let subscription = Channel {
19 id: 1,
20 sub: Subscription::AllMids,
21 };
22
23 ws.subscribe(&[subscription]).await?;
24
25 let handler = |event: Response| async move {
26 println!("Received All Mids: \n--\n{:?}", event);
27
28 Ok(())
29 };
30
31 ws.next(handler).await?;
32
33 ws.disconnect().await?;
34
35 Ok(())
36}