MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / grant_deadline

Function grant_deadline

libatomic/src/daemon/sandbox_grants.rs:228–235  ·  view source on GitHub ↗

The deadline a TTL of `ttl_secs` from `now` means, or [`GrantError::InvalidTtl`]. Checked arithmetic throughout: the TTL comes off the wire, and a request this refuses must be an error, never a panic inside a store's lock.

(now: DateTime<Utc>, ttl_secs: u64)

Source from the content-addressed store, hash-verified

226/// off the wire, and a request this refuses must be an error, never a panic
227/// inside a store's lock.
228pub fn grant_deadline(now: DateTime<Utc>, ttl_secs: u64) -> Result<DateTime<Utc>, GrantError> {
229 if !(MIN_TTL_SECS..=MAX_TTL_SECS).contains(&ttl_secs) {
230 return Err(GrantError::InvalidTtl);
231 }
232 let secs = i64::try_from(ttl_secs).map_err(|_| GrantError::InvalidTtl)?;
233 let ttl = Duration::try_seconds(secs).ok_or(GrantError::InvalidTtl)?;
234 now.checked_add_signed(ttl).ok_or(GrantError::InvalidTtl)
235}
236
237/// A requested capability list as a grant's set: nonempty, and every entry
238/// delegable.

Callers 2

openMethod · 0.85
renewMethod · 0.85

Calls 1

containsMethod · 0.45

Tested by

no test coverage detected