df_hyperliquid_core/live/feed.rs
1//! What a socket feed hands back and why it refuses, the same for the native and the browser
2//! feed (`client::native::Feed`, `client::web::Feed`).
3
4use crate::live::{BadFrame, Frame, Refused, Retry};
5
6/// What a feed hands back, in the order it happened.
7#[derive(Debug, Clone, PartialEq, Eq)]
8pub enum Event {
9 /// The socket opened and everything wanted was subscribed again.
10 Opened,
11 /// Boxed: a frame is large and most events are not frames.
12 Frame(Box<Frame>),
13 /// A frame that did not read. The socket is still alive.
14 Unreadable(BadFrame),
15 /// The socket closed, or could not open. The feed dials again after
16 /// `retry.after_ms`; the posts in `retry.unanswered` may or may not have
17 /// landed, so read the account to find out.
18 Closed { reason: String, retry: Retry },
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
22pub enum FeedError {
23 #[error(transparent)]
24 Refused(#[from] Refused),
25 /// The feed is gone for good. In the browser this also means the runtime gave no timer
26 /// (no `setTimeout`, or one that threw), so the feed could not keep its time.
27 #[error("the feed has stopped")]
28 Stopped,
29}