grafos_leasekit/
renewable.rs

1//! The [`RenewableLease`] trait — uniform interface for lease renewal.
2
3use grafos_std::FabricError;
4
5/// Lease lifecycle status.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum LeaseStatus {
8    /// Lease is valid and usable.
9    Active,
10    /// Lease TTL has elapsed and operations should fail.
11    Expired,
12    /// Lease status could not be determined reliably.
13    Unknown,
14}
15
16/// Uniform interface for renewing a lease regardless of resource type.
17///
18/// Implementors wrap a concrete grafos-std lease type and delegate
19/// `lease_id`, `expires_at_unix_secs`, `renew`, and `status` to the
20/// underlying lease.
21pub trait RenewableLease {
22    /// Returns the unique lease identifier.
23    fn lease_id(&self) -> u128;
24
25    /// Returns the unix timestamp (seconds) at which the lease expires.
26    fn expires_at_unix_secs(&self) -> u64;
27
28    /// Attempt to renew the lease for `duration_secs` additional seconds.
29    fn renew(&mut self, duration_secs: u64) -> Result<(), FabricError>;
30
31    /// Query the current lease status.
32    fn status(&self) -> LeaseStatus;
33}