pub trait DiscoveryContext: Send + Sync {
// Required methods
fn alloc_face_id(&self) -> FaceId;
fn add_face(&self, face: Arc<dyn ErasedFace>) -> FaceId;
fn remove_face(&self, face_id: FaceId);
fn add_fib_entry(
&self,
prefix: &Name,
nexthop: FaceId,
cost: u32,
owner: ProtocolId,
);
fn remove_fib_entry(
&self,
prefix: &Name,
nexthop: FaceId,
owner: ProtocolId,
);
fn remove_fib_entries_by_owner(&self, owner: ProtocolId);
fn neighbors(&self) -> Arc<dyn NeighborTableView>;
fn update_neighbor(&self, update: NeighborUpdate);
fn send_on(&self, face_id: FaceId, pkt: Bytes);
fn now(&self) -> Instant;
}Expand description
Narrow interface through which discovery protocols mutate engine state.
The engine implements this trait on a context struct that holds Arc
references to the face table, FIB, and neighbor table. Protocol
implementations only see this interface, making them easy to unit-test
with a stub context.
Required Methods§
Sourcefn alloc_face_id(&self) -> FaceId
fn alloc_face_id(&self) -> FaceId
Allocate a unique FaceId from the engine’s face table.
Discovery protocols call this before constructing a face object (e.g.
[NamedEtherFace::new]) that requires an ID at construction time.
Sourcefn add_face(&self, face: Arc<dyn ErasedFace>) -> FaceId
fn add_face(&self, face: Arc<dyn ErasedFace>) -> FaceId
Add a dynamically created face to the engine.
Returns the FaceId assigned by the face table. The engine spawns
recv/send tasks and begins forwarding through the face immediately.
Sourcefn remove_face(&self, face_id: FaceId)
fn remove_face(&self, face_id: FaceId)
Remove a face from the engine, stopping its tasks.
Sourcefn add_fib_entry(
&self,
prefix: &Name,
nexthop: FaceId,
cost: u32,
owner: ProtocolId,
)
fn add_fib_entry( &self, prefix: &Name, nexthop: FaceId, cost: u32, owner: ProtocolId, )
Install a FIB route owned by owner.
Routes tagged with a ProtocolId can be bulk-removed via
[remove_fib_entries_by_owner] when the protocol shuts down or
reconfigures.
Sourcefn remove_fib_entry(&self, prefix: &Name, nexthop: FaceId, owner: ProtocolId)
fn remove_fib_entry(&self, prefix: &Name, nexthop: FaceId, owner: ProtocolId)
Remove a single FIB nexthop.
Sourcefn remove_fib_entries_by_owner(&self, owner: ProtocolId)
fn remove_fib_entries_by_owner(&self, owner: ProtocolId)
Remove every FIB route installed by owner.
Sourcefn neighbors(&self) -> Arc<dyn NeighborTableView>
fn neighbors(&self) -> Arc<dyn NeighborTableView>
Read access to the engine-owned neighbor table.
Sourcefn update_neighbor(&self, update: NeighborUpdate)
fn update_neighbor(&self, update: NeighborUpdate)
Apply a mutation to the engine-owned neighbor table.