Skip to main content

Inputs

Struct Inputs 

Source
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 References

The resolved references.

§presence: &'a dyn Presence

Presence.

§mode: ReasoningMode

The 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: i64

Now, 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more