samotop-core 0.13.1+smtp

The domain model of Samotop and core functionality - SMTP server and library built on async-std. A base crate for samotop extensions.
Documentation
use super::SmtpHost;
use crate::common::*;

#[derive(Eq, PartialEq, Debug, Clone)]
pub enum SmtpPath {
    Mailbox {
        name: String,
        host: SmtpHost,
        relays: Vec<SmtpHost>,
    },
    Postmaster,
    Null,
}

impl SmtpPath {
    pub fn address(&self) -> String {
        match *self {
            SmtpPath::Null => String::new(),
            SmtpPath::Postmaster => "POSTMASTER".to_owned(),
            SmtpPath::Mailbox {
                ref name, ref host, ..
            } => format!("{}@{}", name, host),
        }
    }
}

impl fmt::Display for SmtpPath {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "<{}>", self.address())
    }
}