pub trait RenewableSource: RemoteSource {
// Required methods
fn renew(&self, lease: &Lease) -> Result<Lease, Error>;
fn revoke(&self, lease: &Lease) -> Result<(), Error>;
}Expand description
A store whose documents are issued under a lease that can be extended or handed back.
Implemented by a store that issues dynamic credentials — Vault’s
database/creds, pki/issue, aws/creds — where the document is not a
value somebody wrote but a credential the store minted for this reader
alone, with an expiry.
Two lifetimes are in play and conflating them is the mistake this trait
exists to avoid. The credential the client authenticates with is
already handled by the store crates’ Cached, refreshed before it
expires and re-obtained when it is refused. The lease the document was
issued under is this one: a caller renews it on a timer whether or not
anybody reads, and hands it back when it stops needing it.
Blocking, with no async twin, because the stores that issue leases are the blocking ones — a caller with a runtime already drives them through its own blocking pool. If an async store ever grows leases, that is the moment to add the twin, and not before.
Required Methods§
Sourcefn renew(&self, lease: &Lease) -> Result<Lease, Error>
fn renew(&self, lease: &Lease) -> Result<Lease, Error>
Extends a lease, answering with what the store granted.
A store may grant less than was asked for, and the answer is authoritative: schedule the next renewal from what came back, never from what was requested.
§Errors
If the store refuses or cannot be reached. A refusal is terminal for this lease — the credential has to be fetched afresh — while an unreachable store is worth retrying inside the remaining life.
Sourcefn revoke(&self, lease: &Lease) -> Result<(), Error>
fn revoke(&self, lease: &Lease) -> Result<(), Error>
Hands a lease back, so the credential stops working now rather than at expiry.
Best-effort by nature: a caller doing this on the way out has somewhere else to be, and an unreachable store must not keep a process alive. The lease expires on its own regardless; revoking only shortens the window.
§Errors
If the store refuses or cannot be reached.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".