ergot_base/interface_manager/profiles/
null.rs1use serde::Serialize;
8
9use crate::{
10 Header,
11 interface_manager::{ConstInit, InterfaceSendError, InterfaceState, Profile, SetStateError},
12};
13
14pub struct Null {
16 _priv: (),
17}
18
19impl ConstInit for Null {
20 const INIT: Self = Self { _priv: () };
21}
22
23impl Profile for Null {
24 type InterfaceIdent = ();
25
26 fn send<T: Serialize>(&mut self, hdr: &Header, _data: &T) -> Result<(), InterfaceSendError> {
27 if hdr.dst.net_node_any() {
28 Err(InterfaceSendError::DestinationLocal)
29 } else {
30 Err(InterfaceSendError::NoRouteToDest)
31 }
32 }
33
34 fn send_raw(
35 &mut self,
36 hdr: &Header,
37 _hdr_raw: &[u8],
38 _data: &[u8],
39 ) -> Result<(), InterfaceSendError> {
40 if hdr.dst.net_node_any() {
41 Err(InterfaceSendError::DestinationLocal)
42 } else {
43 Err(InterfaceSendError::NoRouteToDest)
44 }
45 }
46
47 fn send_err(
48 &mut self,
49 hdr: &Header,
50 _err: crate::ProtocolError,
51 ) -> Result<(), InterfaceSendError> {
52 if hdr.dst.net_node_any() {
53 Err(InterfaceSendError::DestinationLocal)
54 } else {
55 Err(InterfaceSendError::NoRouteToDest)
56 }
57 }
58
59 fn interface_state(&mut self, _ident: Self::InterfaceIdent) -> Option<InterfaceState> {
60 None
61 }
62
63 fn set_interface_state(
64 &mut self,
65 _ident: Self::InterfaceIdent,
66 _state: InterfaceState,
67 ) -> Result<(), crate::interface_manager::SetStateError> {
68 Err(SetStateError::InterfaceNotFound)
69 }
70}