use std::collections::HashSet; #[derive(Clone)] pub struct ClientState { pub is_tls_established: bool, pub mail_transaction: MailTransaction, pub has_ehloed: bool, pub auth_state: AuthState, pub authed_user: Option>, } #[derive(Clone)] pub struct MailTransaction { pub sender: Option>, pub recipients: HashSet>, pub body: Vec, pub is_receiving_data: bool, } #[derive(Clone, PartialEq)] pub enum AuthState { NotStarted, Plain, Completed, } impl ClientState { pub fn new() -> Self { Self { is_tls_established: false, mail_transaction: MailTransaction::new(), has_ehloed: false, auth_state: AuthState::NotStarted, authed_user: None, } } pub fn reset(&mut self) { self.mail_transaction.reset(); self.auth_state = AuthState::NotStarted; self.authed_user = None; } } impl MailTransaction { fn new() -> Self { Self { sender: None, recipients: HashSet::new(), body: Vec::new(), is_receiving_data: false, } } pub fn reset(&mut self) { self.sender = None; self.recipients.clear(); self.body.clear(); self.is_receiving_data = false; } }