Skip to main content

ckb_jsonrpc_types/
subscription.rs

1use serde::{Deserialize, Serialize};
2
3/// Specifies the topic which to be added as active subscription.
4#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
5#[serde(rename_all = "snake_case")]
6pub enum Topic {
7    /// Subscribe new tip headers.
8    NewTipHeader,
9    /// Subscribe new tip blocks.
10    NewTipBlock,
11    /// Subscribe new transactions which are submitted to the pool.
12    NewTransaction,
13    /// Subscribe in-pool transactions which proposed on chain.
14    ProposedTransaction,
15    /// Subscribe transactions which are abandoned by tx-pool.
16    RejectedTransaction,
17    /// Subscribe to logs.
18    Log,
19}
20
21/// Log entry received from the subscription.
22#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
23pub struct LogEntry {
24    /// The log message.
25    pub message: String,
26    /// The log level.
27    pub level: LogLevel,
28    /// The log target
29    pub target: String,
30    /// The date
31    pub date: String,
32}
33
34/// Log level for log subscription.
35#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
36#[serde(rename_all = "snake_case")]
37pub enum LogLevel {
38    /// Error level.
39    Error,
40    /// Warn level.
41    Warn,
42    /// Info level.
43    Info,
44    /// Debug level.
45    Debug,
46    /// Trace level.
47    Trace,
48}