pub struct Inputs<'a> {
pub refs: &'a References,
pub presence: &'a dyn Presence,
pub mode: ReasoningMode,
pub disabled: &'a [String],
pub history: &'a [Outcome],
pub peers: &'a [LinkedPeer],
pub now: i64,
pub cooldown: Option<i64>,
}Expand description
Everything availability reads besides the catalogue: presence, the mode, the disable
list, the recorded outcomes, the linked peers and the clock. Holding them in one value
is what keeps derive_availability pure.
use majordomus_cli::reasoning::availability::*;
use majordomus_cli::reasoning::catalogue::{AdvisorCatalogue, References};
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();
let refs = References::default();
let disabled = vec!["all".to_string()];
let inputs = Inputs {
refs: &refs, presence: &All, mode: ReasoningMode::Strict, disabled: &disabled,
history: &[], peers: &[], now: 0, cooldown: None,
};
let states = derive_availability(&c, &inputs);
assert_eq!(states[0].status, AdvisorStatus::Disabled);
assert_eq!(states[0].reason, "disabled_by_configuration");Fields§
§refs: &'a ReferencesThe resolved references.
presence: &'a dyn PresencePresence.
mode: ReasoningModeThe mode.
disabled: &'a [String]Advisor ids left out explicitly; all leaves out every one.
history: &'a [Outcome]ReasoningRecorded consultation outcomes, any order.
peers: &'a [LinkedPeer]Linked reviewing peers.
now: i64Now, seconds since the epoch.
cooldown: Option<i64>A cooldown override for every circuit, seconds.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Inputs<'a>
impl<'a> !Send for Inputs<'a>
impl<'a> !Sync for Inputs<'a>
impl<'a> !UnwindSafe for Inputs<'a>
impl<'a> Freeze for Inputs<'a>
impl<'a> Unpin for Inputs<'a>
impl<'a> UnsafeUnpin for Inputs<'a>
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