1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
mod body;
mod helo;

use super::Rfc5321;
use crate::common::*;
use crate::smtp::*;

/// An implementation of LMTP - RFC 2033 - Local Mail Transfer Protocol
#[derive(Eq, PartialEq, Debug, Clone)]
pub struct LMTP;

pub type Rfc2033 = LMTP;

impl Rfc2033 {
    pub fn command<I>(instruction: I) -> LMTPCommand<I> {
        LMTPCommand { instruction }
    }
}

#[derive(Eq, PartialEq, Debug, Clone)]
pub struct LMTPCommand<I> {
    instruction: I,
}

impl SmtpSessionCommand for LMTPCommand<SmtpCommand> {
    fn verb(&self) -> &str {
        self.instruction.verb()
    }

    fn apply(&self, state: SmtpState) -> S2Fut<SmtpState> {
        use SmtpCommand as C;
        Box::pin(async move {
            match self.instruction {
                C::Helo(ref helo) => Rfc2033::apply_cmd(helo, state).await,
                ref cmd => Rfc5321::apply_cmd(cmd, state).await,
            }
        })
    }
}