pub enum Freshness {
Current,
Stale,
Pending,
}Expand description
How a reading stands against the repository as it is now.
use majordomus_cli::capability::readings::{read, Freshness, Patience};
use majordomus_cli::synthetic::SyntheticRepository;
use std::time::Duration;
let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
// a caller with no patience at all is told the first reading is pending, or handed it
// when the worker was quicker than the caller: never anything in between
let none = Patience { cold: Duration::ZERO, moved: Duration::ZERO };
let first = read(&ctx, "plan.status", serde_json::json!({}), none);
assert!(matches!(first.freshness, Freshness::Pending | Freshness::Current));
// and a caller that waits is handed a current one; nothing here moved the repository,
// so nothing is `Freshness::Stale`
let waited = read(&ctx, "plan.status", serde_json::json!({}), Patience::WAIT);
assert_eq!(waited.freshness, Freshness::Current);
assert_ne!(waited.freshness, Freshness::Stale);Variants§
Current
Read in the repository as it is now.
Stale
Read before the repository last moved.
Pending
Never read in this process; the first reading has not arrived.
Trait Implementations§
impl Copy for Freshness
impl Eq for Freshness
impl StructuralPartialEq for Freshness
Auto Trait Implementations§
impl Freeze for Freshness
impl RefUnwindSafe for Freshness
impl Send for Freshness
impl Sync for Freshness
impl Unpin for Freshness
impl UnsafeUnpin for Freshness
impl UnwindSafe for Freshness
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
Mutably borrows from an owned value. Read more
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<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
Compare self to
key and return true if they are equal.