1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
5#[serde(rename_all = "lowercase")]
6pub enum ListDirection {
7 Send,
9 Receive,
11 Reply,
13 #[serde(other)]
15 Unknown,
16}
17
18impl ListDirection {
19 pub(crate) fn as_path(self) -> &'static str {
21 match self {
22 ListDirection::Send => "send",
23 ListDirection::Receive => "receive",
24 ListDirection::Reply => "reply",
25 ListDirection::Unknown => "unknown",
26 }
27 }
28}
29
30#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
32#[serde(rename_all = "lowercase")]
33pub enum ListKind {
34 Allow,
36 Block,
38 #[serde(other)]
40 Unknown,
41}
42
43impl ListKind {
44 pub(crate) fn as_path(self) -> &'static str {
46 match self {
47 ListKind::Allow => "allow",
48 ListKind::Block => "block",
49 ListKind::Unknown => "unknown",
50 }
51 }
52}
53
54#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
56#[serde(rename_all = "lowercase")]
57pub enum EntryType {
58 Email,
60 Domain,
62 #[serde(other)]
64 Unknown,
65}
66
67#[derive(Clone, Debug, Deserialize)]
69pub struct ListEntry {
70 pub entry: String,
72 #[serde(default)]
74 pub reason: Option<String>,
75 #[serde(default = "unknown_entry_type")]
77 pub entry_type: EntryType,
78 #[serde(default)]
80 pub organization_id: Option<String>,
81 #[serde(default)]
83 pub read_only: bool,
84 #[serde(default)]
86 pub created_at: Option<String>,
87}
88
89fn unknown_entry_type() -> EntryType {
90 EntryType::Unknown
91}
92
93#[derive(Clone, Debug, Default, Serialize)]
95pub struct CreateListEntry {
96 pub entry: String,
98 #[serde(skip_serializing_if = "Option::is_none")]
100 pub reason: Option<String>,
101}
102
103#[derive(Clone, Debug, Deserialize)]
105pub struct ListEntries {
106 pub count: u64,
108 #[serde(default)]
110 pub entries: Vec<ListEntry>,
111 #[serde(default)]
113 pub next_page_token: Option<String>,
114}