pub struct Outcome {
pub id: String,
pub advisor: String,
pub status: ConsultationStatus,
pub at: i64,
pub retry_after: Option<u64>,
}Expand description
The recorded outcome of one consultation, as availability reads it: the advisor, how the consultation ended and when. The circuit is computed from these alone.
use majordomus_cli::reasoning::availability::*;
use majordomus_cli::reasoning::catalogue::{AdvisorCatalogue, References};
use majordomus_cli::reasoning::record::ConsultationStatus;
struct All;
impl Presence for All {
fn executable(&self, _: &str) -> bool { true }
fn variable(&self, _: &str) -> bool { true }
}
let c: AdvisorCatalogue = majordomus_cli::metadata::yaml::parse_into(
"version: 1\ncapabilities:\n - id: code_review\n description: x\nadvisors:\n - id: a\n title: A\n transport: cli\n adapter: a-cli\n executable: a\n capabilities: [code_review]\n",
).unwrap();
// a refused credential keeps the advisor out for AUTH_COOLDOWN seconds
let refused = [Outcome {
id: "consultation-1".into(), advisor: "a".into(),
status: ConsultationStatus::AuthFailed, at: 0, retry_after: None,
}];
let refs = References::default();
let at = |now| derive_availability(&c, &Inputs {
refs: &refs, presence: &All, mode: ReasoningMode::Standard, disabled: &[],
history: &refused, peers: &[], now, cooldown: None,
})[0].reason.clone();
assert_eq!(at(1), "authentication_failed");
assert_eq!(at(AUTH_COOLDOWN), "present");Fields§
§id: StringThe consultation record id; the tie-break of equal stamps.
advisor: StringThe advisor asked.
status: ConsultationStatusHow it ended.
at: i64When it was recorded, seconds since the epoch.
retry_after: Option<u64>A rate limit’s own retry-after, seconds.
Trait Implementations§
impl Eq for Outcome
impl StructuralPartialEq for Outcome
Auto Trait Implementations§
impl Freeze for Outcome
impl RefUnwindSafe for Outcome
impl Send for Outcome
impl Sync for Outcome
impl Unpin for Outcome
impl UnsafeUnpin for Outcome
impl UnwindSafe for Outcome
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.