pub struct SessionManager { /* private fields */ }Expand description
Tracks open sessions, identity staleness, and the mutation lease.
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(
identity: ProxyIdentity,
resources: BTreeMap<ResourceId, MmioResource>,
ceiling: BTreeMap<ResourceId, ResourceCeiling>,
allow_mutating_sessions: bool,
) -> Self
pub fn new( identity: ProxyIdentity, resources: BTreeMap<ResourceId, MmioResource>, ceiling: BTreeMap<ResourceId, ResourceCeiling>, allow_mutating_sessions: bool, ) -> Self
Creates a manager for one proxy instance.
Sourcepub fn with_limits(
identity: ProxyIdentity,
resources: BTreeMap<ResourceId, MmioResource>,
ceiling: BTreeMap<ResourceId, ResourceCeiling>,
allow_mutating_sessions: bool,
limit_enforcer: AccessLimitEnforcer,
) -> Self
pub fn with_limits( identity: ProxyIdentity, resources: BTreeMap<ResourceId, MmioResource>, ceiling: BTreeMap<ResourceId, ResourceCeiling>, allow_mutating_sessions: bool, limit_enforcer: AccessLimitEnforcer, ) -> Self
Creates a manager with explicit access limit enforcer.
Sourcepub fn set_quiesce_hook(&mut self, hook: QuiesceHook)
pub fn set_quiesce_hook(&mut self, hook: QuiesceHook)
Registers a synchronous quiesce callback invoked with true when a
mutating session opens and false when it closes.
Sourcepub fn is_quiesced(&self) -> bool
pub fn is_quiesced(&self) -> bool
Returns whether the driver is currently quiesced due to an active mutating session.
Sourcepub fn quiesce_flag(&self) -> Arc<AtomicBool> ⓘ
pub fn quiesce_flag(&self) -> Arc<AtomicBool> ⓘ
Returns a cloneable handle to the atomic quiesce flag so driver background loops can check quiesce state without locking.
Sourcepub fn identity(&self) -> &ProxyIdentity
pub fn identity(&self) -> &ProxyIdentity
The identity Describe reports and expectations are checked
against.
Sourcepub fn resources(&self) -> &BTreeMap<ResourceId, MmioResource>
pub fn resources(&self) -> &BTreeMap<ResourceId, MmioResource>
The resource descriptions offered by this instance.
Sourcepub fn open_session(
&mut self,
context: RunContext,
mode: SessionMode,
expectations: &ProxyIdentity,
allowlist: impl IntoIterator<Item = AccessRule>,
) -> Result<u64, OpenError>
pub fn open_session( &mut self, context: RunContext, mode: SessionMode, expectations: &ProxyIdentity, allowlist: impl IntoIterator<Item = AccessRule>, ) -> Result<u64, OpenError>
Opens a session. Stale identity is rejected before allowlist validation; a rejected allowlist creates no session.
Sourcepub fn check_access(
&mut self,
session_id: u64,
class: AccessClass,
now_ns: i64,
) -> Result<(), Denial>
pub fn check_access( &mut self, session_id: u64, class: AccessClass, now_ns: i64, ) -> Result<(), Denial>
Enforces access-class rate limit for session_id.
Sourcepub fn check_deadline(
&self,
session_id: u64,
requested_timeout_ns: i64,
) -> Result<(), Denial>
pub fn check_deadline( &self, session_id: u64, requested_timeout_ns: i64, ) -> Result<(), Denial>
Enforces deadline limit for session_id.
Sourcepub fn close_session(&mut self, id: u64) -> bool
pub fn close_session(&mut self, id: u64) -> bool
Closes a session, releasing the mutation lease and unquiescing the driver if it held the lease. Returns whether the session existed.
Sourcepub fn reject_new_sessions(&mut self)
pub fn reject_new_sessions(&mut self)
Stop path: reject all new sessions and release any active mutation lease / quiesce state.
Sourcepub fn is_accepting(&self) -> bool
pub fn is_accepting(&self) -> bool
Whether new sessions are being accepted.
Sourcepub fn open_count(&self) -> usize
pub fn open_count(&self) -> usize
Number of open sessions.