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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use super::*;
#[derive(Debug)]
pub struct NullMessageWrite;
impl MessageWrite for NullMessageWrite {
fn set_msg_type(&mut self, _: MsgType) {}
fn set_msg_id(&mut self, _: u16) {}
fn set_msg_code(&mut self, _: MsgCode) {}
fn set_msg_token(&mut self, _: MsgToken) {}
fn append_payload_bytes(&mut self, _: &[u8]) -> Result<(), Error> {
Ok(())
}
fn clear(&mut self) {}
}
impl OptionInsert for NullMessageWrite {
fn insert_option_with_bytes(&mut self, _key: OptionNumber, _value: &[u8]) -> Result<(), Error> {
Ok(())
}
}
#[derive(Debug)]
pub struct NullMessageRead;
impl MessageRead for NullMessageRead {
fn msg_code(&self) -> MsgCode {
MsgCode::Empty
}
fn msg_type(&self) -> MsgType {
MsgType::Res
}
fn msg_id(&self) -> u16 {
0x0000
}
fn msg_token(&self) -> MsgToken {
MsgToken::EMPTY
}
fn payload(&self) -> &[u8] {
&[]
}
fn content_format(&self) -> Option<ContentFormat> {
None
}
fn accept(&self) -> Option<ContentFormat> {
None
}
fn block2(&self) -> Option<BlockInfo> {
None
}
fn block1(&self) -> Option<BlockInfo> {
None
}
fn options(&self) -> OptionIterator<'_> {
OptionIterator::new(&[])
}
}
impl std::fmt::Display for NullMessageRead {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
MessageDisplay(self).fmt(f)
}
}