pub struct CompositeDiscovery { /* private fields */ }Expand description
Wrapper that runs multiple DiscoveryProtocol implementations in parallel.
§Namespace safety
CompositeDiscovery::new returns an error if any two protocols claim
overlapping name prefixes (one is a prefix of the other). Each protocol
must use a distinct sub-tree of /ndn/local/.
§Inbound routing
When a raw packet arrives, CompositeDiscovery tries to parse its top-level
NDN name and routes it to the first protocol whose claimed_prefixes contains
a matching prefix. If the name cannot be parsed or no protocol matches, the
packet is not consumed (returns false).
§Tick delivery
All protocols receive every on_tick call. Order is not guaranteed.
Implementations§
Source§impl CompositeDiscovery
impl CompositeDiscovery
Sourcepub fn new(protocols: Vec<Arc<dyn DiscoveryProtocol>>) -> Result<Self, String>
pub fn new(protocols: Vec<Arc<dyn DiscoveryProtocol>>) -> Result<Self, String>
Construct a composite from a list of protocols.
Returns Err with a human-readable message if any two protocols claim
overlapping prefixes.
pub fn is_empty(&self) -> bool
Sourcepub fn all_claimed_prefixes(&self) -> Vec<Name>
pub fn all_claimed_prefixes(&self) -> Vec<Name>
Collect all prefixes claimed by any child protocol.
Unlike claimed_prefixes() (which returns the composite’s own
top-level claims), this method flattens the claims of all children.
Use this to enumerate the full set of prefixes owned by the discovery
stack (e.g. for management security enforcement).
Trait Implementations§
Source§impl DiscoveryProtocol for CompositeDiscovery
impl DiscoveryProtocol for CompositeDiscovery
Source§fn protocol_id(&self) -> ProtocolId
fn protocol_id(&self) -> ProtocolId
Source§fn claimed_prefixes(&self) -> &[Name]
fn claimed_prefixes(&self) -> &[Name]
Source§fn on_face_up(&self, face_id: FaceId, ctx: &dyn DiscoveryContext)
fn on_face_up(&self, face_id: FaceId, ctx: &dyn DiscoveryContext)
FaceTable::insert).Source§fn on_face_down(&self, face_id: FaceId, ctx: &dyn DiscoveryContext)
fn on_face_down(&self, face_id: FaceId, ctx: &dyn DiscoveryContext)
FaceTable::remove).Source§fn on_inbound(
&self,
raw: &Bytes,
incoming_face: FaceId,
meta: &InboundMeta,
ctx: &dyn DiscoveryContext,
) -> bool
fn on_inbound( &self, raw: &Bytes, incoming_face: FaceId, meta: &InboundMeta, ctx: &dyn DiscoveryContext, ) -> bool
Source§fn on_tick(&self, now: Instant, ctx: &dyn DiscoveryContext)
fn on_tick(&self, now: Instant, ctx: &dyn DiscoveryContext)
tick_interval. Read moreSource§fn tick_interval(&self) -> Duration
fn tick_interval(&self) -> Duration
on_tick. Read more