pub trait LinkMedium:
Send
+ Sync
+ 'static {
// Required methods
fn protocol_id(&self) -> ProtocolId;
fn build_hello_data(&self, core: &HelloCore, interest_name: &Name) -> Bytes;
fn handle_hello_interest(
&self,
raw: &Bytes,
incoming_face: FaceId,
meta: &InboundMeta,
core: &HelloCore,
ctx: &dyn DiscoveryContext,
) -> bool;
fn verify_and_ensure_peer(
&self,
raw: &Bytes,
payload: &HelloPayload,
meta: &InboundMeta,
core: &HelloCore,
ctx: &dyn DiscoveryContext,
) -> Option<(Name, Option<FaceId>)>;
fn send_multicast(&self, ctx: &dyn DiscoveryContext, pkt: Bytes);
fn is_multicast_face(&self, face_id: FaceId) -> bool;
fn on_face_down(
&self,
face_id: FaceId,
state: &mut HelloState,
ctx: &dyn DiscoveryContext,
);
fn on_peer_removed(&self, entry: &NeighborEntry, state: &mut HelloState);
}Expand description
Abstraction over link-layer differences between discovery protocols.
Implementations provide the link-specific operations (face creation,
address extraction, packet signing) while the shared SWIM/hello/probe
state machine lives in HelloProtocol<T>.
Required Methods§
Sourcefn protocol_id(&self) -> ProtocolId
fn protocol_id(&self) -> ProtocolId
Protocol identifier (e.g. "udp-nd", "ether-nd").
Sourcefn build_hello_data(&self, core: &HelloCore, interest_name: &Name) -> Bytes
fn build_hello_data(&self, core: &HelloCore, interest_name: &Name) -> Bytes
Build the hello Data reply for the given Interest name.
UDP signs with Ed25519; Ethernet uses an unsigned placeholder.
Sourcefn handle_hello_interest(
&self,
raw: &Bytes,
incoming_face: FaceId,
meta: &InboundMeta,
core: &HelloCore,
ctx: &dyn DiscoveryContext,
) -> bool
fn handle_hello_interest( &self, raw: &Bytes, incoming_face: FaceId, meta: &InboundMeta, core: &HelloCore, ctx: &dyn DiscoveryContext, ) -> bool
Handle a hello Interest (link-specific dispatch).
Extracts the source address from meta, performs any link-specific
actions (e.g. passive detection for new MACs), builds and sends the
reply via ctx.send_on. Returns true if the Interest was consumed.
Sourcefn verify_and_ensure_peer(
&self,
raw: &Bytes,
payload: &HelloPayload,
meta: &InboundMeta,
core: &HelloCore,
ctx: &dyn DiscoveryContext,
) -> Option<(Name, Option<FaceId>)>
fn verify_and_ensure_peer( &self, raw: &Bytes, payload: &HelloPayload, meta: &InboundMeta, core: &HelloCore, ctx: &dyn DiscoveryContext, ) -> Option<(Name, Option<FaceId>)>
Verify signature (if applicable), extract source address, and ensure a unicast face to the peer exists.
Called by HelloProtocol::handle_hello_data after the shared code has
parsed the hello Data, extracted the nonce, and decoded the
HelloPayload.
Returns (responder_name, optional_face_id) on success, or None
to silently drop the packet.
Sourcefn send_multicast(&self, ctx: &dyn DiscoveryContext, pkt: Bytes)
fn send_multicast(&self, ctx: &dyn DiscoveryContext, pkt: Bytes)
Send a packet on all multicast face(s).
Sourcefn is_multicast_face(&self, face_id: FaceId) -> bool
fn is_multicast_face(&self, face_id: FaceId) -> bool
Whether face_id is one of this medium’s multicast faces.
Sourcefn on_face_down(
&self,
face_id: FaceId,
state: &mut HelloState,
ctx: &dyn DiscoveryContext,
)
fn on_face_down( &self, face_id: FaceId, state: &mut HelloState, ctx: &dyn DiscoveryContext, )
Handle face-down event (clean up link-specific state).
Sourcefn on_peer_removed(&self, entry: &NeighborEntry, state: &mut HelloState)
fn on_peer_removed(&self, entry: &NeighborEntry, state: &mut HelloState)
Clean up link-specific state when a peer is being removed (reached miss_limit in the liveness state machine).