Skip to main content

LinkManager

Struct LinkManager 

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

Manages multiple links, link destinations, and request/response.

Implementations§

Source§

impl LinkManager

Source

pub fn new() -> Self

Create a new empty link manager.

Source

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

Register a destination that can accept incoming links.

Deregister a link destination.

Source

pub fn register_request_handler<F>( &mut self, path: &str, allowed_list: Option<Vec<[u8; 16]>>, handler: F, )
where F: Fn(LinkId, &str, &[u8], Option<&([u8; 16], [u8; 64])>) -> Option<Vec<u8>> + Send + 'static,

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

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.

Source

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.

Source

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.

Source

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.

Send encrypted data on a link with a given context.

Source

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

Tear down a link.

Source

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

Source

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.

Source

pub fn set_resource_strategy( &mut self, link_id: &LinkId, strategy: ResourceStrategy, )

Set the resource acceptance strategy for a link.

Source

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.

Source

pub fn tick(&mut self, rng: &mut dyn Rng) -> Vec<LinkManagerAction>

Periodic tick: check keepalive, stale, timeouts for all links.

Check if a destination hash is a known link_id managed by this manager.

Get the state of a link.

Get the RTT of a link.

Get the number of active links.

Get information about all active links.

Source

pub fn resource_entries(&self) -> Vec<ResourceInfoEntry>

Get information about all active resource transfers.

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