jacquard_host_support/decay_window.rs
1//! Shared decay-window type for engines that age observations by tick count.
2//!
3//! `DecayWindow` configures how many ticks an observation or route entry
4//! remains fresh and how soon the next engine refresh should run. Proactive
5//! next-hop engines (BATMAN variants, Babel, OLSRv2) use this primitive to
6//! prune stale per-neighbor evidence and keep refresh cadence legible.
7// proc-macro-scope: host support primitive intentionally stays outside #[public_model].
8
9use serde::{Deserialize, Serialize};
10
11/// Per-engine staleness and refresh window configuration.
12///
13/// `stale_after_ticks` is the number of ticks an observation may age before it
14/// is dropped. `next_refresh_within_ticks` is the upper bound on how soon the
15/// next engine tick should refresh derived tables.
16#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, Serialize)]
17pub struct DecayWindow {
18 pub stale_after_ticks: u64,
19 pub next_refresh_within_ticks: u64,
20}
21
22impl DecayWindow {
23 #[must_use]
24 pub const fn new(stale_after_ticks: u64, next_refresh_within_ticks: u64) -> Self {
25 Self {
26 stale_after_ticks,
27 next_refresh_within_ticks,
28 }
29 }
30}
31
32impl Default for DecayWindow {
33 fn default() -> Self {
34 Self {
35 stale_after_ticks: 8,
36 next_refresh_within_ticks: 4,
37 }
38 }
39}