async_coap/message/
null.rs1use super::*;
17
18#[derive(Debug)]
20pub struct NullMessageWrite;
21impl MessageWrite for NullMessageWrite {
22 fn set_msg_type(&mut self, _: MsgType) {}
23
24 fn set_msg_id(&mut self, _: u16) {}
25
26 fn set_msg_code(&mut self, _: MsgCode) {}
27
28 fn set_msg_token(&mut self, _: MsgToken) {}
29
30 fn append_payload_bytes(&mut self, _: &[u8]) -> Result<(), Error> {
31 Ok(())
32 }
33
34 fn clear(&mut self) {}
35}
36
37impl OptionInsert for NullMessageWrite {
38 fn insert_option_with_bytes(&mut self, _key: OptionNumber, _value: &[u8]) -> Result<(), Error> {
39 Ok(())
40 }
41}
42
43#[derive(Debug)]
45pub struct NullMessageRead;
46impl MessageRead for NullMessageRead {
47 fn msg_code(&self) -> MsgCode {
48 MsgCode::Empty
49 }
50
51 fn msg_type(&self) -> MsgType {
52 MsgType::Res
53 }
54
55 fn msg_id(&self) -> u16 {
56 0x0000
57 }
58
59 fn msg_token(&self) -> MsgToken {
60 MsgToken::EMPTY
61 }
62
63 fn payload(&self) -> &[u8] {
64 &[]
65 }
66
67 fn content_format(&self) -> Option<ContentFormat> {
68 None
69 }
70
71 fn accept(&self) -> Option<ContentFormat> {
72 None
73 }
74 fn block2(&self) -> Option<BlockInfo> {
75 None
76 }
77 fn block1(&self) -> Option<BlockInfo> {
78 None
79 }
80
81 fn options(&self) -> OptionIterator<'_> {
82 OptionIterator::new(&[])
83 }
84}
85
86impl std::fmt::Display for NullMessageRead {
87 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
88 MessageDisplay(self).fmt(f)
89 }
90}