Skip to main content

df_hyperliquid_core/live/frame/
reply.rs

1//! A post's answer, by the id it was sent with: what `/info` or `/exchange` would have answered,
2//! or what HTTP would have said when the post was not taken.
3
4use crate::client::ExchangeResponse;
5
6/// The answer to a post, by the id it was sent with.
7#[derive(Debug, Clone, PartialEq, Eq)]
8#[non_exhaustive]
9pub struct Reply {
10    /// The id the post was sent with.
11    pub id: u64,
12    /// What came back.
13    pub answer: Answer,
14}
15
16/// What came back for a post, by the `type` of the response.
17#[derive(Debug, Clone, PartialEq, Eq)]
18#[non_exhaustive]
19pub enum Answer {
20    /// What `/info` would have answered, as written (`null` for an unknown coin's book), for a
21    /// read's own type to deserialize.
22    Info {
23        /// The `type` of the info answer.
24        kind: String,
25        /// Its `data` as written JSON; `null` when the answer has none.
26        data: String,
27    },
28    /// What `/exchange` would have answered.
29    Action(ExchangeResponse),
30    /// The post was not taken: what HTTP would have said.
31    Error(String),
32}
33
34#[cfg(test)]
35#[path = "tests/reply.rs"]
36mod tests;