pub struct CtlCallbacks { /* private fields */ }Expand description
Callbacks implementation that bridges rns-net events into shared state + WebSocket broadcast.
Implementations§
Source§impl CtlCallbacks
impl CtlCallbacks
pub fn new(state: SharedState, ws_broadcast: WsBroadcast) -> Self
Trait Implementations§
Source§impl Callbacks for CtlCallbacks
impl Callbacks for CtlCallbacks
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, )
Source§fn 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.Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn 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).
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn on_direct_connect_established(
&mut self,
link_id: LinkId,
interface_id: InterfaceId,
)
fn on_direct_connect_established( &mut self, link_id: LinkId, interface_id: InterfaceId, )
Called when a direct P2P connection is established via hole punching.
Source§fn on_direct_connect_failed(&mut self, link_id: LinkId, reason: u8)
fn on_direct_connect_failed(&mut self, link_id: LinkId, reason: u8)
Called when a direct connection attempt fails.
Source§fn on_interface_up(&mut self, _id: InterfaceId)
fn on_interface_up(&mut self, _id: InterfaceId)
Called when an interface comes online.
Source§fn on_interface_down(&mut self, _id: InterfaceId)
fn on_interface_down(&mut self, _id: InterfaceId)
Called when an interface goes offline.
Source§fn 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.
Source§fn on_direct_connect_proposed(
&mut self,
_link_id: LinkId,
_peer_identity: Option<IdentityHash>,
) -> bool
fn on_direct_connect_proposed( &mut self, _link_id: LinkId, _peer_identity: Option<IdentityHash>, ) -> bool
Called when a direct connection is proposed by a peer (for AskApp policy).
Return true to accept, false to reject.
Auto Trait Implementations§
impl Freeze for CtlCallbacks
impl RefUnwindSafe for CtlCallbacks
impl Send for CtlCallbacks
impl Sync for CtlCallbacks
impl Unpin for CtlCallbacks
impl UnsafeUnpin for CtlCallbacks
impl UnwindSafe for CtlCallbacks
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> InterfaceConfigData for Twhere
T: Send + 'static,
impl<T> InterfaceConfigData for Twhere
T: Send + 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more