2026-06-01 13:39:48 -06:00
|
|
|
mod connections;
|
|
|
|
|
mod hook_output;
|
2026-05-28 14:46:47 -06:00
|
|
|
mod hooks;
|
2026-06-01 13:39:48 -06:00
|
|
|
mod queues;
|
2026-05-28 11:48:46 -06:00
|
|
|
mod routing;
|
2026-05-27 11:04:22 -06:00
|
|
|
|
2026-05-28 14:46:47 -06:00
|
|
|
pub use hooks::HookID;
|
|
|
|
|
|
2026-06-01 13:08:26 -06:00
|
|
|
use alloc::vec::Vec;
|
2026-05-27 11:04:22 -06:00
|
|
|
|
2026-05-31 14:47:25 -06:00
|
|
|
use crate::{
|
|
|
|
|
crypto::Counter,
|
2026-06-01 13:39:48 -06:00
|
|
|
protocol::{ConnectionSet, HookMap, Path, RouteMap},
|
2026-05-31 14:47:25 -06:00
|
|
|
};
|
2026-05-27 11:04:22 -06:00
|
|
|
|
2026-06-01 13:39:48 -06:00
|
|
|
/// Local routing state for one protocol node.
|
|
|
|
|
///
|
|
|
|
|
/// `Endpoint` deliberately owns only route, hook, and connection tables. Leaves are
|
|
|
|
|
/// caller-owned concrete values, which keeps small firmware-style binaries from
|
|
|
|
|
/// linking dynamic leaf registries or boxed trait objects.
|
2026-05-27 11:04:22 -06:00
|
|
|
pub struct Endpoint {
|
2026-06-01 13:39:48 -06:00
|
|
|
/// This endpoint's identifier.
|
2026-05-28 11:48:46 -06:00
|
|
|
pub id: u32,
|
|
|
|
|
|
2026-06-01 13:39:48 -06:00
|
|
|
/// Counter used to allocate locally unique hook ids.
|
2026-05-31 14:47:25 -06:00
|
|
|
pub(crate) last_hook: Counter,
|
2026-05-27 11:04:22 -06:00
|
|
|
|
2026-06-01 13:39:48 -06:00
|
|
|
/// Absolute path for this node. An empty path means routing is not initialized.
|
2026-05-27 11:04:22 -06:00
|
|
|
pub path: Path,
|
|
|
|
|
|
2026-06-01 13:39:48 -06:00
|
|
|
/// Adjacent endpoints and whether each adjacent endpoint is upstream/authority.
|
2026-05-27 11:04:22 -06:00
|
|
|
pub connections: ConnectionSet,
|
|
|
|
|
|
2026-06-01 13:39:48 -06:00
|
|
|
/// Active hook id to adjacent peer mappings.
|
2026-05-28 11:48:46 -06:00
|
|
|
pub(crate) hooks: HookMap,
|
|
|
|
|
|
2026-06-01 13:39:48 -06:00
|
|
|
/// Packets delivered locally and waiting for leaf consumption.
|
2026-05-28 11:48:46 -06:00
|
|
|
pub(crate) inbound: RouteMap,
|
2026-06-01 13:39:48 -06:00
|
|
|
|
|
|
|
|
/// Packets queued for adjacent endpoints and waiting for transport leaves.
|
2026-05-28 11:48:46 -06:00
|
|
|
pub(crate) outbound: RouteMap,
|
2026-05-27 11:04:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Endpoint {
|
2026-06-01 13:08:26 -06:00
|
|
|
/// Creates endpoint routing state for one protocol node.
|
|
|
|
|
///
|
|
|
|
|
/// Leaves are intentionally owned by the caller instead of stored behind
|
|
|
|
|
/// endpoint-local trait objects. That keeps minimized binaries from pulling in
|
|
|
|
|
/// dynamic dispatch and allocation paths when a firmware-style application uses a
|
|
|
|
|
/// fixed set of concrete leaves.
|
|
|
|
|
pub fn new(id: u32) -> Self {
|
2026-05-27 11:04:22 -06:00
|
|
|
Self {
|
2026-05-28 11:48:46 -06:00
|
|
|
id,
|
|
|
|
|
// Init the hook at 0, which will increment
|
2026-05-31 14:47:25 -06:00
|
|
|
last_hook: Counter::new(),
|
2026-05-28 11:48:46 -06:00
|
|
|
|
|
|
|
|
// Set the current path as an empty vec
|
|
|
|
|
path: Vec::new(),
|
2026-06-01 13:08:26 -06:00
|
|
|
hooks: Vec::new(),
|
|
|
|
|
connections: Vec::new(),
|
|
|
|
|
inbound: Vec::new(),
|
|
|
|
|
outbound: Vec::new(),
|
2026-05-27 11:04:22 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|