use crate::nodes::SystemNodeId;
pub const UNKNOWN_ROUTE_STARTING_ID: u32 = 1_000_000;
pub fn is_unknown_route_id(id: SystemNodeId) -> bool {
id >= SystemNodeId::from(UNKNOWN_ROUTE_STARTING_ID)
}
#[non_exhaustive]
#[derive(Debug)]
pub enum RouterError {
RouterFullError,
}
pub trait Router {
type Address;
fn route(&mut self, id: &SystemNodeId) -> Option<&Self::Address>;
fn inverse(&mut self, address: &Self::Address) -> Option<&SystemNodeId>;
fn register(&mut self, address: Self::Address) -> Option<SystemNodeId>;
fn unregister(&mut self, id: SystemNodeId) -> Option<Self::Address>;
fn drop(&mut self, address: Self::Address) -> Option<SystemNodeId>;
fn update(&mut self, source: SystemNodeId, address: Self::Address) -> Result<(), RouterError>;
fn keep(&mut self, id: SystemNodeId, status: bool);
fn clean(&mut self);
}