pub struct FreshnessPolicy {
pub fresh_minutes: Option<i64>,
pub stale_minutes: Option<i64>,
}Expand description
session.freshness: of the policy: how old a continuation record may be before it stops
being current.
These are the only numbers that decide it, and they are declared once. Divergence
(exact/advanced/diverged/different_context) answers a different question — where
the record’s commit sits relative to HEAD — and answers it identically on the day a
record is written and a month later. Keeping a default here would be a second source of
truth for the same thresholds, so absence is carried as absence and reported as
unknown, naming the missing key.
Both keys are independently optional, and the pair is what
Thresholds::judge needs:
with one of them missing it has no band to place a record in and answers unknown
rather than inventing the other half.
use majordomus_cli::policy::FreshnessPolicy;
use serde_json::json;
// the declared form: the two numbers that draw fresh | aging | stale
let declared: FreshnessPolicy =
serde_json::from_value(json!({"fresh_minutes": 30, "stale_minutes": 240})).unwrap();
assert_eq!(declared.fresh_minutes, Some(30));
assert_eq!(declared.stale_minutes, Some(240));
// a policy that predates the key: absent, not defaulted. Nothing in this file
// supplies a number the repository never declared.
let silent: FreshnessPolicy = serde_json::from_value(json!({})).unwrap();
assert_eq!(silent, FreshnessPolicy::default());
assert!(silent.fresh_minutes.is_none() && silent.stale_minutes.is_none());Fields§
§fresh_minutes: Option<i64>Below this age a record is fresh.
stale_minutes: Option<i64>At or beyond this age a record is stale, and is never presented as current.
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 moreSource§impl Debug for FreshnessPolicy
impl Debug for FreshnessPolicy
Source§impl Default for FreshnessPolicy
impl Default for FreshnessPolicy
Source§fn default() -> FreshnessPolicy
fn default() -> FreshnessPolicy
Source§impl<'de> Deserialize<'de> for FreshnessPolicy
impl<'de> Deserialize<'de> for FreshnessPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for FreshnessPolicy
Source§impl PartialEq for FreshnessPolicy
impl PartialEq for FreshnessPolicy
Source§fn eq(&self, other: &FreshnessPolicy) -> bool
fn eq(&self, other: &FreshnessPolicy) -> bool
self and other values to be equal, and is used by ==.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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.