pub trait Callbacks: Send {
Show 18 methods
// Required methods
fn on_announce(&mut self, announced: AnnouncedIdentity);
fn on_path_updated(&mut self, dest_hash: DestHash, hops: u8);
fn on_local_delivery(
&mut self,
dest_hash: DestHash,
raw: Vec<u8>,
packet_hash: PacketHash,
);
// Provided methods
fn on_interface_up(&mut self, _id: InterfaceId) { ... }
fn on_interface_down(&mut self, _id: InterfaceId) { ... }
fn on_link_established(
&mut self,
_link_id: LinkId,
_dest_hash: DestHash,
_rtt: f64,
_is_initiator: bool,
) { ... }
fn on_link_closed(
&mut self,
_link_id: LinkId,
_reason: Option<TeardownReason>,
) { ... }
fn on_remote_identified(
&mut self,
_link_id: LinkId,
_identity_hash: IdentityHash,
_public_key: [u8; 64],
) { ... }
fn on_resource_received(
&mut self,
_link_id: LinkId,
_data: Vec<u8>,
_metadata: Option<Vec<u8>>,
) { ... }
fn on_resource_completed(&mut self, _link_id: LinkId) { ... }
fn on_resource_failed(&mut self, _link_id: LinkId, _error: String) { ... }
fn on_resource_progress(
&mut self,
_link_id: LinkId,
_received: usize,
_total: usize,
) { ... }
fn on_resource_accept_query(
&mut self,
_link_id: LinkId,
_resource_hash: Vec<u8>,
_transfer_size: u64,
_has_metadata: bool,
) -> bool { ... }
fn on_channel_message(
&mut self,
_link_id: LinkId,
_msgtype: u16,
_payload: Vec<u8>,
) { ... }
fn on_link_data(&mut self, _link_id: LinkId, _context: u8, _data: Vec<u8>) { ... }
fn on_response(
&mut self,
_link_id: LinkId,
_request_id: [u8; 16],
_data: Vec<u8>,
) { ... }
fn on_proof(
&mut self,
_dest_hash: DestHash,
_packet_hash: PacketHash,
_rtt: f64,
) { ... }
fn on_proof_requested(
&mut self,
_dest_hash: DestHash,
_packet_hash: PacketHash,
) -> bool { ... }
}Expand description
Callbacks for events the driver produces.
All identifiers use typed wrappers (DestHash, IdentityHash, LinkId, PacketHash)
for compile-time safety.
Required Methods§
fn on_announce(&mut self, announced: AnnouncedIdentity)
fn on_path_updated(&mut self, dest_hash: DestHash, hops: u8)
fn on_local_delivery( &mut self, dest_hash: DestHash, raw: Vec<u8>, packet_hash: PacketHash, )
Provided Methods§
Sourcefn on_interface_up(&mut self, _id: InterfaceId)
fn on_interface_up(&mut self, _id: InterfaceId)
Called when an interface comes online.
Sourcefn on_interface_down(&mut self, _id: InterfaceId)
fn on_interface_down(&mut self, _id: InterfaceId)
Called when an interface goes offline.
Sourcefn on_link_established(
&mut self,
_link_id: LinkId,
_dest_hash: DestHash,
_rtt: f64,
_is_initiator: bool,
)
fn on_link_established( &mut self, _link_id: LinkId, _dest_hash: DestHash, _rtt: f64, _is_initiator: bool, )
Called when a link is fully established.
Sourcefn on_link_closed(&mut self, _link_id: LinkId, _reason: Option<TeardownReason>)
fn on_link_closed(&mut self, _link_id: LinkId, _reason: Option<TeardownReason>)
Called when a link is closed.
Sourcefn on_remote_identified(
&mut self,
_link_id: LinkId,
_identity_hash: IdentityHash,
_public_key: [u8; 64],
)
fn on_remote_identified( &mut self, _link_id: LinkId, _identity_hash: IdentityHash, _public_key: [u8; 64], )
Called when a remote peer identifies on a link.
Sourcefn on_resource_received(
&mut self,
_link_id: LinkId,
_data: Vec<u8>,
_metadata: Option<Vec<u8>>,
)
fn on_resource_received( &mut self, _link_id: LinkId, _data: Vec<u8>, _metadata: Option<Vec<u8>>, )
Called when a resource transfer delivers data.
Sourcefn on_resource_completed(&mut self, _link_id: LinkId)
fn on_resource_completed(&mut self, _link_id: LinkId)
Called when a resource transfer completes (sender-side proof validated).
Sourcefn on_resource_failed(&mut self, _link_id: LinkId, _error: String)
fn on_resource_failed(&mut self, _link_id: LinkId, _error: String)
Called when a resource transfer fails.
Sourcefn on_resource_progress(
&mut self,
_link_id: LinkId,
_received: usize,
_total: usize,
)
fn on_resource_progress( &mut self, _link_id: LinkId, _received: usize, _total: usize, )
Called with resource transfer progress updates.
Sourcefn on_resource_accept_query(
&mut self,
_link_id: LinkId,
_resource_hash: Vec<u8>,
_transfer_size: u64,
_has_metadata: bool,
) -> bool
fn on_resource_accept_query( &mut self, _link_id: LinkId, _resource_hash: Vec<u8>, _transfer_size: u64, _has_metadata: bool, ) -> bool
Called to ask whether to accept an incoming resource (for AcceptApp strategy). Return true to accept, false to reject.
Sourcefn on_channel_message(
&mut self,
_link_id: LinkId,
_msgtype: u16,
_payload: Vec<u8>,
)
fn on_channel_message( &mut self, _link_id: LinkId, _msgtype: u16, _payload: Vec<u8>, )
Called when a channel message is received on a link.
Sourcefn on_link_data(&mut self, _link_id: LinkId, _context: u8, _data: Vec<u8>)
fn on_link_data(&mut self, _link_id: LinkId, _context: u8, _data: Vec<u8>)
Called when generic link data is received.
Sourcefn on_response(
&mut self,
_link_id: LinkId,
_request_id: [u8; 16],
_data: Vec<u8>,
)
fn on_response( &mut self, _link_id: LinkId, _request_id: [u8; 16], _data: Vec<u8>, )
Called when a response is received on a link.
Sourcefn on_proof(
&mut self,
_dest_hash: DestHash,
_packet_hash: PacketHash,
_rtt: f64,
)
fn on_proof( &mut self, _dest_hash: DestHash, _packet_hash: PacketHash, _rtt: f64, )
Called when a delivery proof is received for a packet we sent.
rtt is the round-trip time in seconds.
Sourcefn on_proof_requested(
&mut self,
_dest_hash: DestHash,
_packet_hash: PacketHash,
) -> bool
fn on_proof_requested( &mut self, _dest_hash: DestHash, _packet_hash: PacketHash, ) -> bool
Called for ProveApp strategy: should we prove this incoming packet? Return true to generate and send a proof, false to skip.