rns_net/common/
callbacks.rs1use rns_core::transport::types::InterfaceId;
4
5pub trait Callbacks: Send {
6 fn on_announce(&mut self, announced: crate::common::destination::AnnouncedIdentity);
7
8 fn on_path_updated(&mut self, dest_hash: rns_core::types::DestHash, hops: u8);
9
10 fn on_local_delivery(
11 &mut self,
12 dest_hash: rns_core::types::DestHash,
13 raw: Vec<u8>,
14 packet_hash: rns_core::types::PacketHash,
15 );
16
17 fn on_interface_up(&mut self, _id: InterfaceId) {}
19
20 fn on_interface_down(&mut self, _id: InterfaceId) {}
22
23 fn on_link_established(
25 &mut self,
26 _link_id: rns_core::types::LinkId,
27 _dest_hash: rns_core::types::DestHash,
28 _rtt: f64,
29 _is_initiator: bool,
30 ) {
31 }
32
33 fn on_link_closed(
35 &mut self,
36 _link_id: rns_core::types::LinkId,
37 _reason: Option<rns_core::link::TeardownReason>,
38 ) {
39 }
40
41 fn on_remote_identified(
43 &mut self,
44 _link_id: rns_core::types::LinkId,
45 _identity_hash: rns_core::types::IdentityHash,
46 _public_key: [u8; 64],
47 ) {
48 }
49
50 fn on_resource_received(
52 &mut self,
53 _link_id: rns_core::types::LinkId,
54 _data: Vec<u8>,
55 _metadata: Option<Vec<u8>>,
56 ) {
57 }
58
59 fn on_resource_completed(&mut self, _link_id: rns_core::types::LinkId) {}
61
62 fn on_resource_failed(&mut self, _link_id: rns_core::types::LinkId, _error: String) {}
64
65 fn on_resource_progress(
67 &mut self,
68 _link_id: rns_core::types::LinkId,
69 _received: usize,
70 _total: usize,
71 ) {
72 }
73
74 fn on_resource_accept_query(
77 &mut self,
78 _link_id: rns_core::types::LinkId,
79 _resource_hash: Vec<u8>,
80 _transfer_size: u64,
81 _has_metadata: bool,
82 ) -> bool {
83 false
84 }
85
86 fn on_channel_message(
88 &mut self,
89 _link_id: rns_core::types::LinkId,
90 _msgtype: u16,
91 _payload: Vec<u8>,
92 ) {
93 }
94
95 fn on_link_data(&mut self, _link_id: rns_core::types::LinkId, _context: u8, _data: Vec<u8>) {}
97
98 fn on_response(
100 &mut self,
101 _link_id: rns_core::types::LinkId,
102 _request_id: [u8; 16],
103 _data: Vec<u8>,
104 ) {
105 }
106
107 fn on_proof(
110 &mut self,
111 _dest_hash: rns_core::types::DestHash,
112 _packet_hash: rns_core::types::PacketHash,
113 _rtt: f64,
114 ) {
115 }
116
117 fn on_proof_requested(
120 &mut self,
121 _dest_hash: rns_core::types::DestHash,
122 _packet_hash: rns_core::types::PacketHash,
123 ) -> bool {
124 true
125 }
126
127 fn on_direct_connect_proposed(
130 &mut self,
131 _link_id: rns_core::types::LinkId,
132 _peer_identity: Option<rns_core::types::IdentityHash>,
133 ) -> bool {
134 false
135 }
136
137 fn on_direct_connect_established(
139 &mut self,
140 _link_id: rns_core::types::LinkId,
141 _interface_id: InterfaceId,
142 ) {
143 }
144
145 fn on_direct_connect_failed(&mut self, _link_id: rns_core::types::LinkId, _reason: u8) {}
147}