pub struct FreshnessPolicy {
pub skew: TimeDelta,
pub max_age: Option<TimeDelta>,
pub require_issued_at: bool,
}Expand description
How a consumer bounds a document in time before acting on it.
Every field is explicit; there is no “unset means whatever the library felt like” case. See the module documentation for the reasoning and for which constructor to reach for.
Fields§
§skew: TimeDeltaTolerance applied when comparing the document’s timestamps against the
consumer’s own clock, per the allowance in SPEC §4.2. Applied to the
future-dating check and to max_age.
Not applied to expiresAt, which
validate_basic evaluates against the raw
now: that comparison is documented as taking an already-adjusted
instant from the caller, and moving it here would change the meaning of
every existing call site.
max_age: Option<TimeDelta>The oldest issuedAt this consumer will accept, measured back from
now. None means unbounded — the pre-existing behaviour, and the
only setting under which a document carrying neither timestamp can be
accepted.
require_issued_at: boolReject a document that carries no issuedAt at all, with
malformedRequest.
A document with no issuedAt and no expiresAt cannot be placed in
any window, which SPEC §7.2 forbids executing a consequential task on.
Setting this makes that refusal happen at the framework layer with a
code the producer can act on, rather than at the replay guard with one
that says nothing about what to fix.
Implementations§
Source§impl FreshnessPolicy
impl FreshnessPolicy
Sourcepub fn consequential() -> FreshnessPolicy
pub fn consequential() -> FreshnessPolicy
The posture SPEC §7.2 (Bounding the record) describes for a
consequential Trust Task: issuedAt REQUIRED and a bounded
acceptance window (DEFAULT_MAX_AGE), so that every accepted
document sits inside a window the ReplayGuard
can retain a record for.
Sourcepub fn with_max_age(self, max_age: TimeDelta) -> FreshnessPolicy
pub fn with_max_age(self, max_age: TimeDelta) -> FreshnessPolicy
Builder: set the acceptance window.
Sourcepub fn with_skew(self, skew: TimeDelta) -> FreshnessPolicy
pub fn with_skew(self, skew: TimeDelta) -> FreshnessPolicy
Builder: set the clock-skew tolerance.
Sourcepub fn requiring_issued_at(self) -> FreshnessPolicy
pub fn requiring_issued_at(self) -> FreshnessPolicy
Builder: require an in-band issuedAt.
Sourcepub fn record_expiry<P>(
&self,
doc: &TrustTask<P>,
now: DateTime<Utc>,
) -> Option<DateTime<Utc>>
pub fn record_expiry<P>( &self, doc: &TrustTask<P>, now: DateTime<Utc>, ) -> Option<DateTime<Utc>>
The instant at which a record for doc may be dropped — the end of
this consumer’s willingness to execute it, which SPEC §7.2 makes the
same instant as the end of the replay record’s required retention.
expiresAt fixes it where present. Otherwise it is
issuedAt + max_age. None means this policy places no bound on the
document, in which case a consumer MUST NOT execute a consequential
task on it: it has no window in which to retain the record.
Trait Implementations§
Source§impl Clone for FreshnessPolicy
impl Clone for FreshnessPolicy
Source§fn clone(&self) -> FreshnessPolicy
fn clone(&self) -> FreshnessPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for FreshnessPolicy
Source§impl Debug for FreshnessPolicy
impl Debug for FreshnessPolicy
Source§impl Default for FreshnessPolicy
impl Default for FreshnessPolicy
Source§fn default() -> FreshnessPolicy
fn default() -> FreshnessPolicy
The minimum every consumer should apply: reject a future-dated document and reject one whose stated validity interval is empty. Both are producer bugs or forgeries — no conforming producer emits either — so enforcing them costs a correct deployment nothing.
It deliberately sets no max_age. An acceptance window is a
deployment decision (it depends on how long the transport may hold a
message), and a library that guessed one would start silently rejecting
documents that had been arriving for years.
impl Eq for FreshnessPolicy
Source§impl PartialEq for FreshnessPolicy
impl PartialEq for FreshnessPolicy
impl StructuralPartialEq for FreshnessPolicy
Auto Trait Implementations§
impl Freeze for FreshnessPolicy
impl RefUnwindSafe for FreshnessPolicy
impl Send for FreshnessPolicy
impl Sync for FreshnessPolicy
impl Unpin for FreshnessPolicy
impl UnsafeUnpin for FreshnessPolicy
impl UnwindSafe for FreshnessPolicy
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
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
fn as_unordered(&self) -> &Unordered<T>
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Clear for Twhere
T: InitializableFromZeroed + ?Sized,
impl<T> Clear for Twhere
T: InitializableFromZeroed + ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> InitializableFromZeroed for Twhere
T: Default,
impl<T> InitializableFromZeroed for Twhere
T: Default,
Source§unsafe fn initialize(place: *mut T)
unsafe fn initialize(place: *mut T)
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ResourceProvider<()> for T
impl<T> ResourceProvider<()> for T
Source§fn get_resource(&self) -> &()
fn get_resource(&self) -> &()
T.