1use crate::{DestHash, IdentityHash, InterfaceId, LinkId, PacketHash, TeardownReason};
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: DestHash, hops: u8);
9
10 fn on_local_delivery(&mut self, dest_hash: DestHash, raw: Vec<u8>, packet_hash: PacketHash);
11
12 fn on_interface_up(&mut self, _id: InterfaceId) {}
14
15 fn on_interface_down(&mut self, _id: InterfaceId) {}
17
18 fn on_link_established(
20 &mut self,
21 _link_id: LinkId,
22 _dest_hash: DestHash,
23 _rtt: f64,
24 _is_initiator: bool,
25 ) {
26 }
27
28 fn on_link_closed(&mut self, _link_id: LinkId, _reason: Option<TeardownReason>) {}
30
31 fn on_remote_identified(
33 &mut self,
34 _link_id: LinkId,
35 _identity_hash: IdentityHash,
36 _public_key: [u8; 64],
37 ) {
38 }
39
40 fn on_resource_received(
42 &mut self,
43 _link_id: LinkId,
44 _data: Vec<u8>,
45 _metadata: Option<Vec<u8>>,
46 ) {
47 }
48
49 fn on_resource_completed(&mut self, _link_id: LinkId) {}
51
52 fn on_resource_failed(&mut self, _link_id: LinkId, _error: String) {}
54
55 fn on_resource_progress(&mut self, _link_id: LinkId, _received: usize, _total: usize) {}
57
58 fn on_resource_stream_completed(
60 &mut self,
61 _link_id: LinkId,
62 _transfer_id: crate::resource::ResourceTransferId,
63 ) {
64 }
65
66 fn on_resource_stream_failed(
68 &mut self,
69 _link_id: LinkId,
70 _transfer_id: crate::resource::ResourceTransferId,
71 _error: crate::resource::ResourceTransferError,
72 ) {
73 }
74
75 fn on_resource_stream_progress(
77 &mut self,
78 _link_id: LinkId,
79 _transfer_id: crate::resource::ResourceTransferId,
80 _transferred: u64,
81 _total: u64,
82 ) {
83 }
84
85 fn on_resource_file_received(
87 &mut self,
88 _link_id: LinkId,
89 _resource: crate::resource::ReceivedResourceFile,
90 ) {
91 }
92
93 fn on_resource_accept_query(
96 &mut self,
97 _link_id: LinkId,
98 _resource_hash: Vec<u8>,
99 _transfer_size: u64,
100 _has_metadata: bool,
101 ) -> bool {
102 false
103 }
104
105 fn on_channel_message(&mut self, _link_id: LinkId, _msgtype: u16, _payload: Vec<u8>) {}
107
108 fn on_link_data(&mut self, _link_id: LinkId, _context: u8, _data: Vec<u8>) {}
110
111 fn on_response(&mut self, _link_id: LinkId, _request_id: [u8; 16], _data: Vec<u8>) {}
113
114 fn on_response_with_metadata(
116 &mut self,
117 link_id: LinkId,
118 request_id: [u8; 16],
119 data: Vec<u8>,
120 _metadata: Option<Vec<u8>>,
121 ) {
122 self.on_response(link_id, request_id, data);
123 }
124
125 fn on_request_failed(
127 &mut self,
128 _link_id: LinkId,
129 _request_id: [u8; 16],
130 _reason: crate::link_manager::RequestFailure,
131 ) {
132 }
133
134 fn on_proof(&mut self, _dest_hash: DestHash, _packet_hash: PacketHash, _rtt: f64) {}
137
138 fn on_proof_requested(&mut self, _dest_hash: DestHash, _packet_hash: PacketHash) -> bool {
141 true
142 }
143
144 fn on_direct_connect_proposed(
147 &mut self,
148 _link_id: LinkId,
149 _peer_identity: Option<IdentityHash>,
150 ) -> bool {
151 false
152 }
153
154 fn on_direct_connect_established(&mut self, _link_id: LinkId, _interface_id: InterfaceId) {}
156
157 fn on_direct_connect_failed(&mut self, _link_id: LinkId, _reason: u8) {}
159}