neo_email/
status_code.rs

1use serde::{Deserialize, Serialize};
2
3/// # SMTP Status Codes
4///
5/// This enum represents the status codes that the SMTP server can return to client.
6/// 
7/// ## Example
8/// 
9/// ```rust
10/// use neo_email::status_code::StatusCodes;
11/// use neo_email::message::Message;
12/// 
13/// Message::builder()
14///     .status(StatusCodes::AuthenticationSuccessful)
15///     .message("Authenticated".to_string())
16///     .build()
17/// ```
18#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
19pub enum StatusCodes {
20    /// # Help Message
21    HelpMessage = 214,
22    /// # SMTP Service Ready
23    SMTPServiceReady = 220,
24    /// # Service Closing Transmission Channel
25    ServiceClosingTransmissionChannel = 221,
26    /// # Authentication Successful
27    AuthenticationSuccessful = 235,
28    /// # OK
29    OK = 250,
30    /// # User Not Local Will Forward
31    UserNotLocalWillForward = 251,
32    /// # Cannot Verify User But Will Accept Message And Attempt Delivery
33    CannotVerifyUserButWillAcceptMessageAndAttemptDelivery = 252,
34
35    /// # Start Mail Input
36    StartMailInput = 354,
37
38    /// # Service Not Available
39    ServiceNotAvailable = 421,
40    /// # Requested Mail Action Not Taken: Mailbox Unavailable
41    RequestedMailActionNotTakenMailboxUnavailable = 450,
42    /// # Requested Action Aborted: Local Error In Processing
43    RequestedActionAbortedLocalErrorInProcessing = 451,
44    /// # Insufficient System Storage
45    InsufficientSystemStorage = 452,
46    /// # Server Unable To Accommodate Parameters
47    ServerUnableToAccommodateParameters = 455,
48
49    /// # Syntax Error
50    SyntaxError = 500,
51    /// # Syntax Error In Parameters Or Arguments
52    SyntaxErrorInParametersOrArguments = 501,
53    /// # Command Not Implemented
54    CommandNotImplemented = 502,
55    /// # Bad Sequence Of Commands
56    BadSequenceOfCommands = 503,
57    /// # Command Parameter Not Implemented
58    CommandParameterNotImplemented = 504,
59    /// # Server Does Not Accept Mail
60    ServerDoesNotAcceptMail = 521,
61    /// # Authentication Credetials Invalid
62    AuthenticationCredetialsInvalid = 535,
63    /// # Recipient Address Rejected
64    RecipientAddressRejected = 541,
65    /// # Requested Action Not Taken: Mailbox Unavailable
66    RequestedActionNotTakenMailboxUnavailable = 550,
67    /// # User Not Local: Try Forwarding
68    UserNotLocalTryForwarding = 551,
69    /// # Exceeded Storage Allocation
70    ExceededStorageAllocation = 552,
71    /// # Mailbox Name Not Allowed
72    MailboxNameNotAllowed = 553,
73    /// # Transaction Failed
74    TransactionFailed = 554,
75}
76
77/// # Status Codes
78/// 
79/// This struct contains methods for the StatusCodes enum.
80impl StatusCodes {
81    /// # To String
82    /// 
83    /// This function converts the status code to a string.
84    pub fn to_string(&self) -> String {
85        match self {
86            StatusCodes::HelpMessage => "214".to_string(),
87            StatusCodes::SMTPServiceReady => "220".to_string(),
88            StatusCodes::ServiceClosingTransmissionChannel => "221".to_string(),
89            StatusCodes::AuthenticationSuccessful => "235".to_string(),
90            StatusCodes::OK => "250".to_string(),
91            StatusCodes::UserNotLocalWillForward => "251".to_string(),
92            StatusCodes::CannotVerifyUserButWillAcceptMessageAndAttemptDelivery => {
93                "252".to_string()
94            }
95            StatusCodes::StartMailInput => "354".to_string(),
96            StatusCodes::ServiceNotAvailable => "421".to_string(),
97            StatusCodes::RequestedMailActionNotTakenMailboxUnavailable => "450".to_string(),
98            StatusCodes::RequestedActionAbortedLocalErrorInProcessing => "451".to_string(),
99            StatusCodes::InsufficientSystemStorage => "452".to_string(),
100            StatusCodes::ServerUnableToAccommodateParameters => "455".to_string(),
101            StatusCodes::SyntaxError => "500".to_string(),
102            StatusCodes::SyntaxErrorInParametersOrArguments => "501".to_string(),
103            StatusCodes::CommandNotImplemented => "502".to_string(),
104            StatusCodes::BadSequenceOfCommands => "503".to_string(),
105            StatusCodes::CommandParameterNotImplemented => "504".to_string(),
106            StatusCodes::ServerDoesNotAcceptMail => "521".to_string(),
107            StatusCodes::AuthenticationCredetialsInvalid => "535".to_string(),
108            StatusCodes::RecipientAddressRejected => "541".to_string(),
109            StatusCodes::RequestedActionNotTakenMailboxUnavailable => "550".to_string(),
110            StatusCodes::UserNotLocalTryForwarding => "551".to_string(),
111            StatusCodes::ExceededStorageAllocation => "552".to_string(),
112            StatusCodes::MailboxNameNotAllowed => "553".to_string(),
113            StatusCodes::TransactionFailed => "554".to_string(),
114        }
115    }
116}