1#[derive(Debug, PartialEq)]
3pub enum Response {
4 Goodbye,
5 Ok,
6 StartData,
7 TooManyRecipients,
8 SyntaxError,
9 OutOfSequence,
10 NotImplemented,
11 RecipientNotLocal,
12 InvalidRecipient,
13 TransactionFailed,
14 Greeting(String),
15 Helo(String),
16 Ehlo(String),
17}
18
19impl Response {
20 pub fn to_response(&self) -> String {
21 match self {
22 Response::Goodbye => "221 Goodbye!\r\n".into(),
23 Response::Ok => "250 Ok\r\n".into(),
24 Response::StartData => "354 Go ahead\r\n".into(),
25 Response::TooManyRecipients => "452 Too many recipients\r\n".into(),
26 Response::SyntaxError => "500 Syntax error\r\n".into(),
27 Response::OutOfSequence => "503 Command out of sequence\r\n".into(),
28 Response::NotImplemented => "504 Command not implemented\r\n".into(),
29 Response::RecipientNotLocal => "550 User not local\r\n".into(),
30 Response::InvalidRecipient => "554 No valid recipient\r\n".into(),
31 Response::TransactionFailed => "554 Transaction failed\r\n".into(),
32
33 Response::Greeting(name) => format!("220 {} ESMTP\r\n", name),
34 Response::Helo(name) => format!("250 {} ESMTP\r\n", name),
35 Response::Ehlo(name) => format!("250 {} ESMTP\r\n", name),
36 }
37 }
38}