miltr_common/actions/
bidirectional.rs

1use bytes::BytesMut;
2
3use crate::decoding::Parsable;
4use crate::encoding::Writable;
5use crate::ProtocolError;
6
7/// Abort / finish processing a mail.
8///
9/// This Signals the other end to either:
10/// - abort processing of the current mail
11/// - finish up processing if at the end of a mail processing flow
12#[derive(Debug, Clone)]
13pub struct Abort;
14
15impl Parsable for Abort {
16    const CODE: u8 = b'A';
17
18    fn parse(_buffer: BytesMut) -> Result<Self, ProtocolError> {
19        Ok(Self)
20    }
21}
22
23impl Writable for Abort {
24    fn write(&self, _buffer: &mut BytesMut) {}
25
26    fn len(&self) -> usize {
27        0
28    }
29
30    fn code(&self) -> u8 {
31        Self::CODE
32    }
33    fn is_empty(&self) -> bool {
34        self.len() == 0
35    }
36}
37
38/// Continue with the next step in the milter protocol
39#[derive(Debug, Clone)]
40pub struct Continue;
41
42impl Continue {
43    const CODE: u8 = b'c';
44}
45
46impl Parsable for Continue {
47    const CODE: u8 = Self::CODE;
48
49    fn parse(_buffer: BytesMut) -> Result<Self, ProtocolError> {
50        Ok(Self)
51    }
52}
53
54impl Writable for Continue {
55    fn write(&self, _buffer: &mut BytesMut) {}
56
57    fn len(&self) -> usize {
58        0
59    }
60
61    fn code(&self) -> u8 {
62        Self::CODE
63    }
64
65    fn is_empty(&self) -> bool {
66        self.len() == 0
67    }
68}