Skip to main content

CtlCallbacks

Struct CtlCallbacks 

Source
pub struct CtlCallbacks { /* private fields */ }
Expand description

Callbacks implementation that bridges rns-net events into shared state + WebSocket broadcast.

Implementations§

Source§

impl CtlCallbacks

Source

pub fn new(state: SharedState, ws_broadcast: WsBroadcast) -> Self

Trait Implementations§

Source§

impl Callbacks for CtlCallbacks

Source§

fn on_announce(&mut self, announced: AnnouncedIdentity)

Source§

fn on_path_updated(&mut self, _dest_hash: DestHash, _hops: u8)

Source§

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)

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

Called for ProveApp strategy: should we prove this incoming packet? Return true to generate and send a proof, false to skip.
Called when a link is fully established.
Called when a link is closed.
Source§

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>>, )

Called when a resource transfer delivers data.
Source§

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)

Called when a resource transfer fails.
Source§

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

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>, )

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>)

Called when a response is received on a link.
Source§

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)

Called when a direct connection attempt fails.
Source§

fn on_interface_up(&mut self, _id: InterfaceId)

Called when an interface comes online.
Source§

fn on_interface_down(&mut self, _id: InterfaceId)

Called when an interface goes offline.
Called when generic link data is received.
Source§

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InterfaceConfigData for T
where T: Send + 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.