Expand description
HTTP and websocket for the browser and Workers: Web sends requests
through the global fetch, clock is Date.now(), and a Feed keeps
the websocket open over the global WebSocket. Hand the first two to
crate::client::Api:
ⓘ
let api = df_hyperliquid_core::client::Api::new(df_hyperliquid_core::client::web::Web, df_hyperliquid_core::client::Network::Mainnet, df_hyperliquid_core::client::web::clock);and an crate::live::Session to the feed, then read what it hands back:
ⓘ
let mut feed = df_hyperliquid_core::client::web::Feed::start(df_hyperliquid_core::live::Session::new(df_hyperliquid_core::client::Network::Mainnet));
feed.subscribe(df_hyperliquid_core::live::Subscription::AllMids { dex: String::new() }).await?;
while let Some(event) = feed.next().await {
// Opened, Frame, Unreadable, or Closed with the delay before the next dial.
}fetch, WebSocket and setTimeout are read off the global object, so
this runs in a page, a Web Worker, a Cloudflare Worker and Node 22. The API
answers CORS with *. Requests are never retried.
Re-exports§
Modules§
- socket
- The websocket in the browser and Workers: a
Feedcarries onecrate::live::Sessionover the globalWebSocket. Subscriptions made while down are sent on the next open; a post made while down is refused, and one cut off by a drop is reported, never resent.
Structs§
- Web
- The global
fetch.
Functions§
- clock
- Unix milliseconds from
Date.now(): thecrate::client::Clockin the browser and Workers, where std has no clock.