pub struct Patience {
pub cold: Duration,
pub moved: Duration,
}Expand description
How long a read waits for a worker before it returns what it has.
use majordomus_cli::capability::readings::Patience;
use std::time::Duration;
// a page waits a minute for a first reading and 50 ms for a moved repository
assert_eq!(Patience::PAGE.cold, Duration::from_secs(60));
assert_eq!(Patience::PAGE.moved, Duration::from_millis(50));
// an exact read waits for as long as it takes
assert_eq!(Patience::WAIT.moved, Duration::MAX);
let brief = Patience { cold: Duration::from_millis(5), moved: Duration::ZERO };
assert!(brief.moved < Patience::PAGE.moved);Fields§
§cold: DurationFor a source that has never been read in this process.
moved: DurationFor a source read before the repository last moved.
Implementations§
Source§impl Patience
impl Patience
Sourcepub const PAGE: Patience
pub const PAGE: Patience
What a page is served with: a first reading is waited for up to a minute, because there is nothing else to show, and a reading the repository has moved past for 50 ms, half of the 100 ms a warm page is allowed (the owner’s UI-performance pack).
Sourcepub fn of_process() -> Patience
pub fn of_process() -> Patience
The patience of this process: PATIENCE_SWITCH when it is set, and otherwise
Patience::PAGE. The crate’s own unit tests wait, so that a test which renders a
screen asserts on a current reading and never on a timing.
use majordomus_cli::capability::readings::{Patience, PATIENCE_SWITCH};
// what the switch says when it is set and means something, a page's patience otherwise
let set = std::env::var(PATIENCE_SWITCH).ok();
let expected = Patience::parse(set.as_deref()).unwrap_or(Patience::PAGE);
assert_eq!(Patience::of_process(), expected);Sourcepub fn parse(value: Option<&str>) -> Option<Patience>
pub fn parse(value: Option<&str>) -> Option<Patience>
What a value of PATIENCE_SWITCH means, or None when it means nothing: wait
is Patience::WAIT, and a number is that many milliseconds for a repository that
has moved, with a first reading waited for no less than a page waits.
use majordomus_cli::capability::readings::Patience;
assert_eq!(Patience::parse(Some("wait")), Some(Patience::WAIT));
let twenty = Patience::parse(Some(" 20 ")).unwrap();
assert_eq!(twenty.moved.as_millis(), 20);
assert_eq!(twenty.cold, Patience::PAGE.cold, "a first reading is still waited for");
assert_eq!(Patience::parse(Some("soon")), None, "not a number and not `wait`");
assert_eq!(Patience::parse(None), None);Trait Implementations§
impl Copy for Patience
impl Eq for Patience
impl StructuralPartialEq for Patience
Auto Trait Implementations§
impl Freeze for Patience
impl RefUnwindSafe for Patience
impl Send for Patience
impl Sync for Patience
impl Unpin for Patience
impl UnsafeUnpin for Patience
impl UnwindSafe for Patience
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<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.