Skip to main content

Event

Enum Event 

Source
pub enum Event<W: Send> {
Show 32 variants Frame { interface_id: InterfaceId, data: Vec<u8>, }, InterfaceUp(InterfaceId, Option<W>, Option<InterfaceInfo>), InterfaceDown(InterfaceId), Tick, Shutdown, SendOutbound { raw: Vec<u8>, dest_type: u8, attached_interface: Option<InterfaceId>, }, RegisterDestination { dest_hash: [u8; 16], dest_type: u8, }, DeregisterDestination { dest_hash: [u8; 16], }, DeregisterLinkDestination { dest_hash: [u8; 16], }, Query(QueryRequest, Sender<QueryResponse>), RegisterLinkDestination { dest_hash: [u8; 16], sig_prv_bytes: [u8; 32], sig_pub_bytes: [u8; 32], resource_strategy: u8, }, RegisterRequestHandler { path: String, allowed_list: Option<Vec<[u8; 16]>>, handler: Box<dyn Fn([u8; 16], &str, &[u8], Option<&([u8; 16], [u8; 64])>) -> Option<Vec<u8>> + Send>, }, CreateLink { dest_hash: [u8; 16], dest_sig_pub_bytes: [u8; 32], response_tx: Sender<[u8; 16]>, }, SendRequest { link_id: [u8; 16], path: String, data: Vec<u8>, }, IdentifyOnLink { link_id: [u8; 16], identity_prv_key: [u8; 64], }, TeardownLink { link_id: [u8; 16], }, SendResource { link_id: [u8; 16], data: Vec<u8>, metadata: Option<Vec<u8>>, }, SetResourceStrategy { link_id: [u8; 16], strategy: u8, }, AcceptResource { link_id: [u8; 16], resource_hash: Vec<u8>, accept: bool, }, SendChannelMessage { link_id: [u8; 16], msgtype: u16, payload: Vec<u8>, }, SendOnLink { link_id: [u8; 16], data: Vec<u8>, context: u8, }, RequestPath { dest_hash: [u8; 16], }, RegisterProofStrategy { dest_hash: [u8; 16], strategy: ProofStrategy, signing_key: Option<[u8; 64]>, }, ProposeDirectConnect { link_id: [u8; 16], }, SetDirectConnectPolicy { policy: HolePunchPolicy, }, HolePunchProbeResult { link_id: [u8; 16], session_id: [u8; 16], observed_addr: SocketAddr, socket: UdpSocket, probe_server: SocketAddr, }, HolePunchProbeFailed { link_id: [u8; 16], session_id: [u8; 16], }, InterfaceConfigChanged(InterfaceId), LoadHook { name: String, wasm_bytes: Vec<u8>, attach_point: String, priority: i32, response_tx: Sender<Result<(), String>>, }, UnloadHook { name: String, attach_point: String, response_tx: Sender<Result<(), String>>, }, ReloadHook { name: String, attach_point: String, wasm_bytes: Vec<u8>, response_tx: Sender<Result<(), String>>, }, ListHooks { response_tx: Sender<Vec<HookInfo>>, },
}
Expand description

Events sent to the driver thread.

W is the writer type (e.g. Box<dyn Writer> for sync, or a channel sender for async).

Variants§

§

Frame

A decoded frame arrived from an interface.

Fields

§interface_id: InterfaceId
§data: Vec<u8>
§

InterfaceUp(InterfaceId, Option<W>, Option<InterfaceInfo>)

An interface came online after (re)connecting. Carries a new writer if the connection was re-established. Carries InterfaceInfo if this is a new dynamic interface (e.g. TCP server client).

§

InterfaceDown(InterfaceId)

An interface went offline (socket closed, error).

§

Tick

Periodic maintenance tick (1s interval).

§

Shutdown

Shut down the driver loop.

§

SendOutbound

Send an outbound packet.

Fields

§raw: Vec<u8>
§dest_type: u8
§attached_interface: Option<InterfaceId>
§

RegisterDestination

Register a local destination.

Fields

§dest_hash: [u8; 16]
§dest_type: u8
§

DeregisterDestination

Deregister a local destination.

Fields

§dest_hash: [u8; 16]
§

DeregisterLinkDestination

Deregister a link destination (stop accepting incoming links).

Fields

§dest_hash: [u8; 16]
§

Query(QueryRequest, Sender<QueryResponse>)

Query driver state. Response is sent via the provided channel.

§

RegisterLinkDestination

Register a link destination (accepts incoming LINKREQUEST).

Fields

§dest_hash: [u8; 16]
§sig_prv_bytes: [u8; 32]
§sig_pub_bytes: [u8; 32]
§resource_strategy: u8
§

RegisterRequestHandler

Register a request handler for a path on established links.

Fields

§path: String
§allowed_list: Option<Vec<[u8; 16]>>
§handler: Box<dyn Fn([u8; 16], &str, &[u8], Option<&([u8; 16], [u8; 64])>) -> Option<Vec<u8>> + Send>

Create an outbound link. Response sends (link_id) back.

Fields

§dest_hash: [u8; 16]
§dest_sig_pub_bytes: [u8; 32]
§response_tx: Sender<[u8; 16]>
§

SendRequest

Send a request on an established link.

Fields

§link_id: [u8; 16]
§path: String
§data: Vec<u8>

Identify on a link (send identity to remote peer).

Fields

§link_id: [u8; 16]
§identity_prv_key: [u8; 64]

Tear down a link.

Fields

§link_id: [u8; 16]
§

SendResource

Send a resource on a link.

Fields

§link_id: [u8; 16]
§data: Vec<u8>
§metadata: Option<Vec<u8>>
§

SetResourceStrategy

Set the resource acceptance strategy for a link.

Fields

§link_id: [u8; 16]
§strategy: u8
§

AcceptResource

Accept or reject a pending resource (for AcceptApp strategy).

Fields

§link_id: [u8; 16]
§resource_hash: Vec<u8>
§accept: bool
§

SendChannelMessage

Send a channel message on a link.

Fields

§link_id: [u8; 16]
§msgtype: u16
§payload: Vec<u8>

Send generic data on a link with a given context.

Fields

§link_id: [u8; 16]
§data: Vec<u8>
§context: u8
§

RequestPath

Request a path to a destination from the network.

Fields

§dest_hash: [u8; 16]
§

RegisterProofStrategy

Register a proof strategy for a destination.

Fields

§dest_hash: [u8; 16]
§strategy: ProofStrategy
§signing_key: Option<[u8; 64]>

Full identity private key (64 bytes) for signing proofs.

§

ProposeDirectConnect

Propose a direct connection to a peer via hole punching.

Fields

§link_id: [u8; 16]
§

SetDirectConnectPolicy

Set the direct-connect policy.

Fields

§

HolePunchProbeResult

(Internal) Probe result arrived from a worker thread.

Fields

§link_id: [u8; 16]
§session_id: [u8; 16]
§observed_addr: SocketAddr
§socket: UdpSocket
§probe_server: SocketAddr

The probe server that responded successfully.

§

HolePunchProbeFailed

(Internal) Probe failed.

Fields

§link_id: [u8; 16]
§session_id: [u8; 16]
§

InterfaceConfigChanged(InterfaceId)

An interface’s configuration changed (placeholder for future use).

§

LoadHook

Load a WASM hook at runtime.

Fields

§name: String
§wasm_bytes: Vec<u8>
§attach_point: String
§priority: i32
§response_tx: Sender<Result<(), String>>
§

UnloadHook

Unload a WASM hook at runtime.

Fields

§name: String
§attach_point: String
§response_tx: Sender<Result<(), String>>
§

ReloadHook

Reload a WASM hook at runtime (detach + recompile + reattach with same priority).

Fields

§name: String
§attach_point: String
§wasm_bytes: Vec<u8>
§response_tx: Sender<Result<(), String>>
§

ListHooks

List all loaded hooks.

Fields

§response_tx: Sender<Vec<HookInfo>>

Trait Implementations§

Source§

impl<W: Send> Debug for Event<W>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W> Freeze for Event<W>
where W: Freeze,

§

impl<W> !RefUnwindSafe for Event<W>

§

impl<W> Send for Event<W>

§

impl<W> !Sync for Event<W>

§

impl<W> Unpin for Event<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for Event<W>
where W: UnsafeUnpin,

§

impl<W> !UnwindSafe for Event<W>

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