maik 0.2.0

A mock SMTP server library
Documentation
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<Vec<u8>>,
}

#[derive(Clone)]
pub struct MailTransaction {
    pub sender: Option<Vec<u8>>,
    pub recipients: HashSet<Vec<u8>>,
    pub body: Vec<u8>,
    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;
    }
}