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)]
8#[non_exhaustive]
9pub enum Event {
10 /// The socket opened and everything wanted was subscribed again.
11 Opened,
12 /// Boxed: a frame is large and most events are not frames.
13 Frame(Box<Frame>),
14 /// A frame that did not read. The socket is still alive.
15 Unreadable(BadFrame),
16 /// The socket closed, or could not open. The feed dials again after
17 /// `retry.after_ms`; the posts in `retry.unanswered` may or may not have
18 /// landed, so read the account to find out.
19 Closed {
20 /// Why it closed or did not open, as the socket gave it.
21 reason: String,
22 /// When to dial again, and the posts left unanswered.
23 retry: Retry,
24 },
25}
26
27/// Why a feed would not send something, or stopped.
28#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
29#[non_exhaustive]
30pub enum FeedError {
31 /// The session refused it; nothing was sent.
32 #[error(transparent)]
33 Refused(#[from] Refused),
34 /// The feed is gone for good. In the browser this also means the runtime gave no timer
35 /// (no `setTimeout`, or one that threw), so the feed could not keep its time.
36 #[error("the feed has stopped")]
37 Stopped,
38}