1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use std::io;
use smtp_message::{Email, Hostname, Reply};
pub mod reply;
#[must_use]
#[derive(Debug)]
pub enum Decision<T> {
Accept {
reply: Reply,
res: T,
},
Reject {
reply: Reply,
},
Kill {
reply: Option<Reply>,
res: io::Result<()>,
},
}
#[must_use]
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub enum SerializableDecision<T> {
Accept {
reply: Reply,
res: T,
},
Reject {
reply: Reply,
},
Kill {
reply: Option<Reply>,
res: Result<(), String>,
},
}
impl<T> From<SerializableDecision<T>> for Decision<T> {
fn from(d: SerializableDecision<T>) -> Decision<T> {
match d {
SerializableDecision::Accept { reply, res } => Decision::Accept { reply, res },
SerializableDecision::Reject { reply } => Decision::Reject { reply },
SerializableDecision::Kill { reply, res } => Decision::Kill {
reply,
res: res.map_err(|msg| io::Error::new(io::ErrorKind::Other, msg)),
},
}
}
}
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct MailMetadata<U> {
pub user: U,
pub from: Option<Email>,
pub to: Vec<Email>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct HelloInfo {
pub is_extended: bool,
pub hostname: Hostname,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct ConnectionMetadata<U> {
pub user: U,
pub hello: Option<HelloInfo>,
pub is_encrypted: bool,
}