pub struct CursorAffinity { /* private fields */ }Expand description
A bounded, TTL’d map from cursor id to the cluster that created it
(docs/03 §6). Cloneable handles are not provided; wrap in an Arc to share.
Implementations§
Source§impl CursorAffinity
impl CursorAffinity
Sourcepub fn new(ttl: Duration, capacity: usize) -> Self
pub fn new(ttl: Duration, capacity: usize) -> Self
Builds a cursor-affinity map with the given binding TTL and capacity, reading time from the system clock.
Sourcepub fn with_clock(self, clock: Arc<dyn Clock>) -> Self
pub fn with_clock(self, clock: Arc<dyn Clock>) -> Self
Swaps the clock that drives expiry (tests inject a ManualClock).
Sourcepub fn pin(&self, cursor_id: impl Into<String>, cluster: ClusterId)
pub fn pin(&self, cursor_id: impl Into<String>, cluster: ClusterId)
Records that cursor_id lives on cluster. Expired bindings are swept
first; if the map is still at capacity, the oldest binding is evicted so
the new one fits (bounded memory).
Sourcepub fn resolve(&self, cursor_id: &str) -> Option<ClusterId>
pub fn resolve(&self, cursor_id: &str) -> Option<ClusterId>
The cluster cursor_id is pinned to, or None if it is unknown or its
binding has expired (lazy expiry, a stale binding is never returned).
Sourcepub fn release(&self, cursor_id: &str)
pub fn release(&self, cursor_id: &str)
Drops cursor_id’s binding (e.g. on an explicit clear-scroll / close-PIT).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CursorAffinity
impl !RefUnwindSafe for CursorAffinity
impl !UnwindSafe for CursorAffinity
impl Send for CursorAffinity
impl Sync for CursorAffinity
impl Unpin for CursorAffinity
impl UnsafeUnpin for CursorAffinity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more