pub struct LinkManager { /* private fields */ }Expand description
Manages multiple links, link destinations, and request/response.
Implementations§
Source§impl LinkManager
impl LinkManager
Sourcepub fn register_management_path(&mut self, path_hash: [u8; 16])
pub fn register_management_path(&mut self, path_hash: [u8; 16])
Register a path hash as a management path. Management requests are returned as ManagementRequest actions for the driver to handle (since they need access to engine state).
Sourcepub fn register_link_destination(
&mut self,
dest_hash: [u8; 16],
sig_prv: Ed25519PrivateKey,
sig_pub_bytes: [u8; 32],
)
pub fn register_link_destination( &mut self, dest_hash: [u8; 16], sig_prv: Ed25519PrivateKey, sig_pub_bytes: [u8; 32], )
Register a destination that can accept incoming links.
Sourcepub fn deregister_link_destination(&mut self, dest_hash: &[u8; 16])
pub fn deregister_link_destination(&mut self, dest_hash: &[u8; 16])
Deregister a link destination.
Sourcepub fn register_request_handler<F>(
&mut self,
path: &str,
allowed_list: Option<Vec<[u8; 16]>>,
handler: F,
)
pub fn register_request_handler<F>( &mut self, path: &str, allowed_list: Option<Vec<[u8; 16]>>, handler: F, )
Register a request handler for a given path.
path: the request path string (e.g. “/status”)
allowed_list: None = allow all, Some(list) = restrict to these identity hashes
handler: called with (link_id, path, request_data, remote_identity) -> Option
Sourcepub fn create_link(
&mut self,
dest_hash: &[u8; 16],
dest_sig_pub_bytes: &[u8; 32],
hops: u8,
rng: &mut dyn Rng,
) -> (LinkId, Vec<LinkManagerAction>)
pub fn create_link( &mut self, dest_hash: &[u8; 16], dest_sig_pub_bytes: &[u8; 32], hops: u8, rng: &mut dyn Rng, ) -> (LinkId, Vec<LinkManagerAction>)
Create an outbound link to a destination.
dest_sig_pub_bytes is the destination’s Ed25519 signing public key
(needed to verify LRPROOF). In Python this comes from the Destination’s Identity.
Returns (link_id, actions). The first action will be a SendPacket with
the LINKREQUEST.
Sourcepub fn handle_local_delivery(
&mut self,
dest_hash: [u8; 16],
raw: &[u8],
packet_hash: [u8; 32],
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn handle_local_delivery( &mut self, dest_hash: [u8; 16], raw: &[u8], packet_hash: [u8; 32], rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>
Handle a packet delivered locally (via DeliverLocal).
Returns actions for the driver to dispatch. The dest_hash is the
packet’s destination_hash field. raw is the full packet bytes.
packet_hash is the SHA-256 hash.
Sourcepub fn send_management_response(
&self,
link_id: &LinkId,
request_id: &[u8; 16],
response_data: &[u8],
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn send_management_response( &self, link_id: &LinkId, request_id: &[u8; 16], response_data: &[u8], rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>
Send a management response on a link. Called by the driver after building the response for a ManagementRequest.
Sourcepub fn send_request(
&self,
link_id: &LinkId,
path: &str,
data: &[u8],
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn send_request( &self, link_id: &LinkId, path: &str, data: &[u8], rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>
Send a request on a link.
data is the msgpack-encoded request data value (e.g. msgpack([True]) for /status).
Uses Python-compatible format: plaintext = msgpack([timestamp, path_hash_bytes, data_value]). Returns actions (the encrypted request packet). The response will arrive later via handle_local_delivery with CONTEXT_RESPONSE.
Sourcepub fn send_on_link(
&self,
link_id: &LinkId,
plaintext: &[u8],
context: u8,
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn send_on_link( &self, link_id: &LinkId, plaintext: &[u8], context: u8, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>
Send encrypted data on a link with a given context.
Sourcepub fn identify(
&self,
link_id: &LinkId,
identity: &Identity,
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn identify( &self, link_id: &LinkId, identity: &Identity, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>
Send an identify message on a link (initiator reveals identity to responder).
Sourcepub fn teardown_link(&mut self, link_id: &LinkId) -> Vec<LinkManagerAction>
pub fn teardown_link(&mut self, link_id: &LinkId) -> Vec<LinkManagerAction>
Tear down a link.
Sourcepub fn accept_resource(
&mut self,
link_id: &LinkId,
resource_hash: &[u8],
accept: bool,
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn accept_resource( &mut self, link_id: &LinkId, resource_hash: &[u8], accept: bool, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>
Accept or reject a pending resource (for AcceptApp strategy).
Sourcepub fn send_resource(
&mut self,
link_id: &LinkId,
data: &[u8],
metadata: Option<&[u8]>,
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn send_resource( &mut self, link_id: &LinkId, data: &[u8], metadata: Option<&[u8]>, rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>
Start sending a resource on a link.
Sourcepub fn set_resource_strategy(
&mut self,
link_id: &LinkId,
strategy: ResourceStrategy,
)
pub fn set_resource_strategy( &mut self, link_id: &LinkId, strategy: ResourceStrategy, )
Set the resource acceptance strategy for a link.
Sourcepub fn send_channel_message(
&mut self,
link_id: &LinkId,
msgtype: u16,
payload: &[u8],
rng: &mut dyn Rng,
) -> Vec<LinkManagerAction>
pub fn send_channel_message( &mut self, link_id: &LinkId, msgtype: u16, payload: &[u8], rng: &mut dyn Rng, ) -> Vec<LinkManagerAction>
Send a channel message on a link.
Sourcepub fn tick(&mut self, rng: &mut dyn Rng) -> Vec<LinkManagerAction>
pub fn tick(&mut self, rng: &mut dyn Rng) -> Vec<LinkManagerAction>
Periodic tick: check keepalive, stale, timeouts for all links.
Sourcepub fn is_link_destination(&self, dest_hash: &[u8; 16]) -> bool
pub fn is_link_destination(&self, dest_hash: &[u8; 16]) -> bool
Check if a destination hash is a known link_id managed by this manager.
Sourcepub fn link_state(&self, link_id: &LinkId) -> Option<LinkState>
pub fn link_state(&self, link_id: &LinkId) -> Option<LinkState>
Get the state of a link.
Sourcepub fn link_count(&self) -> usize
pub fn link_count(&self) -> usize
Get the number of active links.
Sourcepub fn link_entries(&self) -> Vec<LinkInfoEntry>
pub fn link_entries(&self) -> Vec<LinkInfoEntry>
Get information about all active links.
Sourcepub fn resource_entries(&self) -> Vec<ResourceInfoEntry>
pub fn resource_entries(&self) -> Vec<ResourceInfoEntry>
Get information about all active resource transfers.