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