pub trait Strategy:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &Name;
fn after_receive_interest(
&self,
ctx: &StrategyContext<'_>,
) -> impl Future<Output = SmallVec<[ForwardingAction; 2]>> + Send;
fn after_receive_data(
&self,
ctx: &StrategyContext<'_>,
) -> impl Future<Output = SmallVec<[ForwardingAction; 2]>> + Send;
// Provided methods
fn decide(
&self,
_ctx: &StrategyContext<'_>,
) -> Option<SmallVec<[ForwardingAction; 2]>> { ... }
fn on_interest_timeout(
&self,
_ctx: &StrategyContext<'_>,
) -> impl Future<Output = ForwardingAction> + Send { ... }
fn on_nack(
&self,
_ctx: &StrategyContext<'_>,
_reason: NackReason,
) -> impl Future<Output = ForwardingAction> + Send { ... }
}Expand description
The forwarding strategy trait.
A strategy is a pure decision function — it reads state through
StrategyContext but cannot modify forwarding tables directly.
Autonomous behaviour (probing, discovery) is done via the Probe channel
on StrategyContext.
Required Methods§
Sourcefn after_receive_interest(
&self,
ctx: &StrategyContext<'_>,
) -> impl Future<Output = SmallVec<[ForwardingAction; 2]>> + Send
fn after_receive_interest( &self, ctx: &StrategyContext<'_>, ) -> impl Future<Output = SmallVec<[ForwardingAction; 2]>> + Send
Called when an Interest arrives and needs a forwarding decision.
Sourcefn after_receive_data(
&self,
ctx: &StrategyContext<'_>,
) -> impl Future<Output = SmallVec<[ForwardingAction; 2]>> + Send
fn after_receive_data( &self, ctx: &StrategyContext<'_>, ) -> impl Future<Output = SmallVec<[ForwardingAction; 2]>> + Send
Called when Data arrives and needs to be forwarded to consumers.
Provided Methods§
Sourcefn decide(
&self,
_ctx: &StrategyContext<'_>,
) -> Option<SmallVec<[ForwardingAction; 2]>>
fn decide( &self, _ctx: &StrategyContext<'_>, ) -> Option<SmallVec<[ForwardingAction; 2]>>
Synchronous fast path for forwarding decisions.
Strategies whose after_receive_interest is fully synchronous should
override this to return Some(actions), avoiding the Box::pin heap
allocation in the ErasedStrategy wrapper.
Returns None (default) to fall through to the async path.
Sourcefn on_interest_timeout(
&self,
_ctx: &StrategyContext<'_>,
) -> impl Future<Output = ForwardingAction> + Send
fn on_interest_timeout( &self, _ctx: &StrategyContext<'_>, ) -> impl Future<Output = ForwardingAction> + Send
Called when a PIT entry times out. Default: suppress (let the entry die).
Sourcefn on_nack(
&self,
_ctx: &StrategyContext<'_>,
_reason: NackReason,
) -> impl Future<Output = ForwardingAction> + Send
fn on_nack( &self, _ctx: &StrategyContext<'_>, _reason: NackReason, ) -> impl Future<Output = ForwardingAction> + Send
Called when a Nack arrives on an out-record face.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.