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
40
41
42
43
44
45
46
47
use std::io::Write;
#[cfg(feature = "serdex")]
use serde::{Deserialize, Serialize};
use crate::{codec::Encode, types::core::NString};
#[cfg_attr(feature = "serdex", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Address {
name: NString,
adl: NString,
mailbox: NString,
host: NString,
}
impl Address {
pub fn new(name: NString, adl: NString, mailbox: NString, host: NString) -> Address {
Address {
name,
adl,
mailbox,
host,
}
}
}
impl Encode for Address {
fn encode(&self, writer: &mut impl Write) -> std::io::Result<()> {
writer.write_all(b"(")?;
self.name.encode(writer)?;
writer.write_all(b" ")?;
self.adl.encode(writer)?;
writer.write_all(b" ")?;
self.mailbox.encode(writer)?;
writer.write_all(b" ")?;
self.host.encode(writer)?;
writer.write_all(b")")?;
Ok(())
}
}