qbit_api_rs/types/
log.rs

1use serde::{self, Deserialize, Serialize};
2use serde_repr::*;
3
4/// # `/api/v2/log/main`
5#[derive(Debug, Clone, Serialize)]
6pub struct MainQuery {
7    pub normal: bool,
8    pub info: bool,
9    pub warning: bool,
10    pub critical: bool,
11    pub last_known_id: i64,
12}
13
14impl Default for MainQuery {
15    fn default() -> Self {
16        Self {
17            normal: true,
18            info: true,
19            warning: true,
20            critical: true,
21            last_known_id: -1,
22        }
23    }
24}
25
26/// # `/api/v2/log/main`
27pub type MainResponse = Vec<MainResponseItem>;
28
29/// # `/api/v2/log/main`
30/// [`MainResponse`]
31#[derive(Debug, Clone, Deserialize)]
32pub struct MainResponseItem {
33    pub id: u64,
34    pub message: String,
35    pub timestamp: u64,
36    pub r#type: MainType,
37}
38
39/// # `/api/v2/log/main`
40/// [`MainResponseItem::r#type`]
41#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
42#[repr(u8)]
43pub enum MainType {
44    NORMAL = 1,
45    INFO = 2,
46    WARNING = 4,
47    CRITICAL = 8,
48}
49
50/// # `/api/v2/log/peers`
51#[derive(Debug, Clone, Serialize)]
52pub struct PeersQuery {
53    pub last_known_id: i64,
54}
55
56impl Default for PeersQuery {
57    fn default() -> Self {
58        Self { last_known_id: -1 }
59    }
60}
61
62/// # `/api/v2/log/peers`
63pub type PeersResponse = Vec<PeersResponseItem>;
64
65/// # `/api/v2/log/peers`
66/// [`PeersResponse`]
67#[derive(Debug, Clone, Deserialize)]
68pub struct PeersResponseItem {
69    pub id: u64,
70    pub ip: String,
71    pub timestamp: u64,
72    pub blocked: bool,
73    pub reason: String,
74}