diff options
| -rw-r--r-- | src/smtp.rs | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/smtp.rs b/src/smtp.rs index 30cf490..2795ecf 100644 --- a/src/smtp.rs +++ b/src/smtp.rs @@ -173,20 +173,15 @@ impl SessionHandler { } } -#[derive(PartialEq)] +#[derive(PartialEq, Default)] enum SessionState { + #[default] WaitingHelo, MailTransaction, AwaitingMailInput, Normal, } -impl Default for SessionState { - fn default() -> Self { - Self::WaitingHelo - } -} - enum Reply { Ready(String), Completed(String), @@ -196,15 +191,15 @@ enum Reply { BadSequence, } -impl ToString for Reply { - fn to_string(&self) -> String { +impl std::fmt::Display for Reply { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Reply::Ready(hostname) => format!("220 {}", hostname), - Reply::Completed(hostname) => format!("250 {}", hostname), - Reply::InvalidCommand => format!("500 Invalid command"), - Reply::InvalidParameter => format!("501 Parameter error"), - Reply::BadSequence => format!("503 Bad sequence of commands"), - Reply::StartMailInput => format!("354 <CRLF>.<CRLF>"), + Reply::Ready(hostname) => write!(f, "220 {}", hostname), + Reply::Completed(hostname) => write!(f, "250 {}", hostname), + Reply::InvalidCommand => write!(f, "500 Invalid command"), + Reply::InvalidParameter => write!(f, "501 Parameter error"), + Reply::BadSequence => write!(f, "503 Bad sequence of commands"), + Reply::StartMailInput => write!(f, "354 <CRLF>.<CRLF>"), } } } |
