pub struct SessionStore { /* private fields */ }Expand description
Per-session ad-break records.
A BTreeMap keyed by session id: the records here are small (one
BreakState per session, per the module’s design decision), so there
is no per-peer media state to bound with a cursor count the way
media-plane’s Trunk must. Eviction policy (TTL, LRU, session-end) is
the caller’s concern — this store only exposes Self::end as the
mechanism; deciding when to call it is out of scope for a sans-IO core
with no clock of its own.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn begin_break(
&mut self,
session_id: impl Into<String>,
state: BreakState,
) -> Result<()>
pub fn begin_break( &mut self, session_id: impl Into<String>, state: BreakState, ) -> Result<()>
Start a break for session_id. Errors with
Error::BreakAlreadyActive if the session already has an
unresumed break — call Self::resume or Self::end first.
Sourcepub fn resume(
&mut self,
session_id: &str,
resumed_at: ConditionedSplicePoint,
) -> Result<()>
pub fn resume( &mut self, session_id: &str, resumed_at: ConditionedSplicePoint, ) -> Result<()>
Record the resumption point for session_id’s active break. Errors
with Error::NoActiveBreak if there is no record for the session.
Sourcepub fn get(&self, session_id: &str) -> Option<&BreakState>
pub fn get(&self, session_id: &str) -> Option<&BreakState>
The current break record for session_id, if any. A resumed record
stays until Self::end evicts it, so a caller can still render the
just-ended break’s EXT-X-DATERANGE for one more playlist reload.
Sourcepub fn end(&mut self, session_id: &str) -> Option<BreakState>
pub fn end(&mut self, session_id: &str) -> Option<BreakState>
Evict session_id’s record entirely (session ended, or its break has
aged out of the sliding window). Returns the evicted record, if any.