pub struct LeaseKernel { /* private fields */ }Expand description
In-process registry of active leases.
Implementations§
Source§impl LeaseKernel
impl LeaseKernel
pub fn new() -> Self
pub fn with_clock(clock: Clock) -> Self
Sourcepub fn acquire(
&mut self,
ir_lease: &IRLease,
ir_resource: &IRResource,
) -> Result<LeaseToken, HandlerError>
pub fn acquire( &mut self, ir_lease: &IRLease, ir_resource: &IRResource, ) -> Result<LeaseToken, HandlerError>
Mint a fresh token for a lease against a resource. Rejects persistent resources (defence in depth — the type-checker already did this).
Sourcepub fn use_token(
&mut self,
token: &LeaseToken,
) -> Result<UseOutcome, HandlerError>
pub fn use_token( &mut self, token: &LeaseToken, ) -> Result<UseOutcome, HandlerError>
Verify the token is still valid and apply on_expire policy on decay.
Sourcepub fn release(&mut self, token: &LeaseToken)
pub fn release(&mut self, token: &LeaseToken)
Explicitly revoke a token. Idempotent.
Sourcepub fn sweep(&mut self) -> Vec<LeaseToken>
pub fn sweep(&mut self) -> Vec<LeaseToken>
Purge tokens whose τ has elapsed. Returns the removed tokens.
Sourcepub fn active(&self) -> Vec<LeaseToken>
pub fn active(&self) -> Vec<LeaseToken>
Snapshot of currently-valid tokens.
pub fn contains(&self, token_id: &str) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for LeaseKernel
impl !Sync for LeaseKernel
impl !UnwindSafe for LeaseKernel
impl Freeze for LeaseKernel
impl Send for LeaseKernel
impl Unpin for LeaseKernel
impl UnsafeUnpin for LeaseKernel
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.