pub struct DutyLedger { /* private fields */ }Expand description
The shared duty ledger: one DutyTracker plus the active limit
and modulation parameters, behind a blocking mutex so it can sit in
a static and be consulted from every radio client’s TX path.
All time comes in as caller-supplied now_ms (the same monotonic
clock the session uses), keeping the ledger free of any platform
timer dependency.
Implementations§
Source§impl DutyLedger
impl DutyLedger
pub const fn new() -> Self
Sourcepub fn would_exceed(&self, now_ms: u64, airtime_ms: u32) -> bool
pub fn would_exceed(&self, now_ms: u64, airtime_ms: u32) -> bool
Whether transmitting airtime_ms now would push combined usage
past the active limit.
Sourcepub fn record(&self, now_ms: u64, airtime_ms: u32)
pub fn record(&self, now_ms: u64, airtime_ms: u32)
Record airtime_ms of completed transmission.
Sourcepub fn reset_accounting(&self)
pub fn reset_accounting(&self)
Zero the accounting bins (protocol reset). The limit and modulation parameters are configuration and stay.
pub fn set_limit(&self, limit: u16)
Sourcepub fn set_phy(&self, sf: u8, bw_hz: u32, cr_denom: u8)
pub fn set_phy(&self, sf: u8, bw_hz: u32, cr_denom: u8)
Update the modulation parameters used for Self::airtime_ms.
The session calls this wherever it (re)applies radio settings.
Sourcepub fn airtime_ms(&self, frame_len: usize) -> u32
pub fn airtime_ms(&self, frame_len: usize) -> u32
Airtime of a frame_len-byte frame at the active modulation.
Sourcepub fn admit(&self, now_ms: u64, frame_len: usize) -> Result<u32, DutyExceeded>
pub fn admit(&self, now_ms: u64, frame_len: usize) -> Result<u32, DutyExceeded>
Admission check for a client that knows only its frame length
(the device node’s radio path): compute the airtime at the
active modulation and test it against the combined budget.
Returns the airtime to Self::record once the transmit
completes. Does not itself record — refused frames and failed
transmits must not consume budget.