ErasedStrategy

Trait ErasedStrategy 

Source
pub trait ErasedStrategy:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &Name;
    fn decide_sync(
        &self,
        ctx: &StrategyContext<'_>,
    ) -> Option<SmallVec<[ForwardingAction; 2]>>;
    fn after_receive_interest_erased<'a>(
        &'a self,
        ctx: &'a StrategyContext<'a>,
    ) -> Pin<Box<dyn Future<Output = SmallVec<[ForwardingAction; 2]>> + Send + 'a>>;
    fn on_nack_erased<'a>(
        &'a self,
        ctx: &'a StrategyContext<'a>,
        reason: NackReason,
    ) -> Pin<Box<dyn Future<Output = ForwardingAction> + Send + 'a>>;
}
Expand description

Object-safe version of Strategy that boxes its futures.

Required Methods§

Source

fn name(&self) -> &Name

Canonical name identifying this strategy (e.g. /localhost/nfd/strategy/best-route).

Source

fn decide_sync( &self, ctx: &StrategyContext<'_>, ) -> Option<SmallVec<[ForwardingAction; 2]>>

Synchronous fast path — avoids the Box::pin heap allocation. Returns None to fall through to the async path.

Source

fn after_receive_interest_erased<'a>( &'a self, ctx: &'a StrategyContext<'a>, ) -> Pin<Box<dyn Future<Output = SmallVec<[ForwardingAction; 2]>> + Send + 'a>>

Async path for Interest forwarding decisions (boxed future).

Source

fn on_nack_erased<'a>( &'a self, ctx: &'a StrategyContext<'a>, reason: NackReason, ) -> Pin<Box<dyn Future<Output = ForwardingAction> + Send + 'a>>

Handle an incoming Nack and decide whether to retry or propagate.

Implementors§