pub struct StreamCache { /* private fields */ }Expand description
Cached state for one active voice stream on one module.
Implementations§
Source§impl StreamCache
impl StreamCache
Sourcepub const fn new(
stream_id: StreamId,
header: DStarHeader,
from: SocketAddr,
now: Instant,
) -> Self
pub const fn new( stream_id: StreamId, header: DStarHeader, from: SocketAddr, now: Instant, ) -> Self
Construct a new stream cache entry.
Called when the reflector sees a fresh voice header from a
client. now is the wall-clock instant of receipt, used as
both started_at and the initial last_activity.
Sourcepub const fn new_with_bytes(
stream_id: StreamId,
header: DStarHeader,
header_bytes: Vec<u8>,
from: SocketAddr,
now: Instant,
) -> Self
pub const fn new_with_bytes( stream_id: StreamId, header: DStarHeader, header_bytes: Vec<u8>, from: SocketAddr, now: Instant, ) -> Self
Construct a new stream cache entry with the raw header bytes cached for retransmit.
Preferred entry point for the fan-out engine, which needs to re-send the original wire-format header verbatim every 21 frames without re-encoding it.
Sourcepub fn header_bytes(&self) -> &[u8] ⓘ
pub fn header_bytes(&self) -> &[u8] ⓘ
Raw wire-format bytes of the cached voice header.
Returns an empty slice if the cache was constructed via
Self::new rather than Self::new_with_bytes.
Sourcepub const fn record_frame(&mut self, now: Instant)
pub const fn record_frame(&mut self, now: Instant)
Record the arrival of another voice frame.
Increments the internal sequence counter and refreshes
last_activity so the inactivity watchdog stays armed.
Sourcepub const fn should_rebroadcast_header(&self) -> bool
pub const fn should_rebroadcast_header(&self) -> bool
Whether the cached header should be rebroadcast on the next tick.
Returns true once every 21 frames, matching the xlxd /
MMDVMHost cadence. The boundary is (seq_counter + 1) % 21 == 0
so the first rebroadcast happens after 20 data frames.
Sourcepub fn should_evict(&self, now: Instant, timeout: Duration) -> bool
pub fn should_evict(&self, now: Instant, timeout: Duration) -> bool
Whether this stream has been idle long enough to be evicted.
Sourcepub const fn from(&self) -> SocketAddr
pub const fn from(&self) -> SocketAddr
The peer that originated the stream (so fan-out can avoid echo).
Sourcepub const fn started_at(&self) -> Instant
pub const fn started_at(&self) -> Instant
When the stream first began (useful for duration metrics).
Sourcepub const fn last_activity(&self) -> Instant
pub const fn last_activity(&self) -> Instant
When the last frame was observed (useful for watchdogs / metrics).
Trait Implementations§
Source§impl Clone for StreamCache
impl Clone for StreamCache
Source§fn clone(&self) -> StreamCache
fn clone(&self) -> StreamCache
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more