Skip to main content

ReferenceSession

Struct ReferenceSession 

Source
pub struct ReferenceSession { /* private fields */ }
Expand description

Attends to runs that say what they were authored to say, one thing per pass.

Nothing here happens elsewhere: a run is a count of things left to say, and time passes only when a scenario says it does, so what attendance means can be read without waiting for it.

Trait Implementations§

Source§

impl AttentionAlg for ReferenceSession

Source§

fn begun(&mut self, id: &usize, _holdable: bool)

States that a run has begun, and whether a run of this kind can be held still.
Source§

fn heard(&mut self, id: &usize, _report: usize)

States one thing a run said.
Source§

fn ran_for(&mut self, id: &usize, elapsed: Duration)

States how long a run has been running, not counting the time it was held still.
Source§

fn ended(&mut self, id: &usize, ending: Result<(), String>)

States how a run ended.
Source§

fn wanted(&self, id: &usize) -> Wanted

States what the request wants of its run now.
Source§

impl ClockAlg for ReferenceSession

Source§

type Moment = Duration

Represents one reading of the clock.
Source§

fn now(&self) -> Duration

Reads the clock now.
Source§

fn since(&self, moment: &Duration) -> Duration

States how long it has been since one reading.
Source§

impl Debug for ReferenceSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ReferenceSession

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl RunHoldAlg for ReferenceSession

Source§

fn holding_is_possible(&self) -> bool

States whether a run of this kind can be held still at all.
Source§

fn hold_run(&self, run: &mut ReferenceRun, held: bool)

Holds the run still, or lets it go.
Source§

fn abandon_run(&self, run: &mut ReferenceRun)

Tells the run to end whether or not it has finished. Read more
Source§

impl RunReadAlg for ReferenceSession

Source§

fn run_is_over(&self, run: &ReferenceRun) -> bool

States whether the run is over.
Source§

fn read_run(&self, run: &mut ReferenceRun) -> Vec<usize>

States everything the run has said since it was last read, without waiting for more.
Source§

fn end_run(&self, _run: ReferenceRun) -> Result<(), String>

Waits for a run that is over, and states how it ended. Read more
Source§

impl SessionLawFixture for ReferenceSession

Source§

fn law_wanting(&mut self, says: usize) -> usize

Authors one request wanting work whose run states the given number of things, one per pass, and is over once it has stated them.
Source§

fn law_unbeginnable(&mut self) -> usize

Authors one request whose work refuses to begin.
Source§

fn law_wants(&mut self, id: &usize, wanted: Wanted)

States what one request now wants of its run.
Source§

fn law_passes(&mut self, elapsed: Duration)

Lets the stated time pass.
Source§

fn law_told(&self, id: &usize) -> Vec<Telling>

Observes everything one request was told, in the order it was told.
Source§

fn law_abandonments(&self, id: &usize) -> usize

Observes how many times one run was told to end whether or not it had finished.
Source§

impl SessionSorts for ReferenceSession

Source§

type Id = usize

Names the request one run works on behalf of.
Source§

type Run = ReferenceRun

Represents one thing happening where this program cannot reach into it.
Source§

type Report = usize

Represents one thing a run states while it is happening.
Source§

type Ending = ()

Represents how a run ended.
Source§

type Refusal = String

Denotes a run refusing to begin, to be read, or to end.
Source§

impl UndertakingAlg for ReferenceSession

Source§

fn unattended(&self) -> Vec<usize>

States every request that wants a run and does not have one.
Source§

fn begin(&self, id: &usize) -> Result<ReferenceRun, String>

Begins the work one request asks for. Read more

Auto Trait Implementations§

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<This> GaugeLaws<This> for This

Source§

fn gauge_laws(&self) -> Result<(), Error>

Checks that a gauge states a share without claiming more resolution than it has.

The laws checked are:

  1. a gauge occupies its stated width whatever share it states;
  2. no share is stated as filled before it is reached, and none is stated twice;
  3. nothing stated is nothing filled, and everything stated fills the whole track;
  4. the stated text occupies exactly one cell per counted cell.
§Errors

Returns the first violated law.

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<This> IntoExt<This> for This

Source§

fn to<R>(self) -> R
where This: Into<R>,

A version of Into::into function that can be used to explicitly specify the target conversion type.

use alux_sdk::*;
// `Into` requires context to infer the type,
let _: i64 = Into::into(42_i8);
// The opposite `From` requires context to infer the type,
let _: i64 = From::from(42_i8);
// `.to()` can be used in the same way as a postfix function (the same as `.into()`),
let _: i64 = 42_i8.to();
// but also with the type specified explicitly.
let _ = 42_i8.to::<i64>();
// Especially useful to chain multiple conversions inline.
let _: i64 = 42_i8.to::<i16>().to::<i32>().into();
Source§

impl<This> IntoIteratorExt<This> for This

Source§

fn try_collect_vec<T, E>(self) -> Result<Vec<T>, E>
where This: Iterator<Item = Result<T, E>>,

A variant of the try_collect and collect_vec combined function from the Itertools library. The materialized value is a Vec inside a Result object.

Returns the first error without collecting later values.

use alux_sdk::*;

let values = [Ok::<_, &str>(1), Ok(2), Ok(3)]
    .into_iter()
    .try_collect_vec();

assert_eq!(values, Ok(vec![1, 2, 3]));
Source§

fn collect_exact<T>(self, n: usize) -> Option<Vec<T>>
where This: Iterator<Item = T>,

Takes exactly n elements from the iterator.

Returns Some(Vec<T>) if the iterator yields exactly n elements, otherwise returns None.

use alux_sdk::*;

let v = [1, 2, 3];

assert_eq!(v.iter().copied().collect_exact(3), Some(vec![1, 2, 3]));
assert_eq!(v.iter().copied().collect_exact(4), None);
assert_eq!(v.iter().copied().collect_exact(2), None);
Source§

fn try_unzip<A, B, E>(self) -> Result<(Vec<A>, Vec<B>), E>
where This: IntoIterator<Item = Result<(A, B), E>>,

Efficiently splits an iterator of Result<(A, B), E> into two Vecs, short-circuiting on error.

Consumes the iterator, collecting all A elements into one vector and all B elements into another, without first allocating an intermediate vector of tuples. Returns the tuple (Vec<A>, Vec<B>) on success, or the first error encountered.

use alux_sdk::*;

let input = vec![Ok((1, "x")), Ok((2, "y"))];
let (xs, ys) = input.try_unzip::<_, _, ()>().unwrap();

assert_eq!(xs, vec![1, 2]);
assert_eq!(ys, vec!["x", "y"]);
Source§

impl<This> SessionExt<This> for This

Source§

fn attend( &mut self, running: &mut Vec<Attending<<This as SessionSorts>::Id, <This as SessionSorts>::Run, <This as ClockAlg>::Moment>>, )

Attends to every run once, then begins the work nobody has begun yet.

The order is the meaning. Ending comes before beginning, so leaving never races starting; a run is seen to be over before it is read, so everything it wrote before ending is read; and what it said is stated before how it ended, so nothing it said is lost to its ending.

Source§

fn attend_one( &mut self, attending: &mut Attending<<This as SessionSorts>::Id, <This as SessionSorts>::Run, <This as ClockAlg>::Moment>, ) -> bool

Attends to one run, and states whether it is still running afterward.

Source§

fn hold_still( &self, attending: &mut Attending<<This as SessionSorts>::Id, <This as SessionSorts>::Run, <This as ClockAlg>::Moment>, )

Holds one run still, and remembers when, so held time is not counted as running.

Source§

fn let_go( &self, attending: &mut Attending<<This as SessionSorts>::Id, <This as SessionSorts>::Run, <This as ClockAlg>::Moment>, )

Lets one held run go, keeping the time it was held still.

Source§

fn running_for( &self, attending: &Attending<<This as SessionSorts>::Id, <This as SessionSorts>::Run, <This as ClockAlg>::Moment>, ) -> Duration

States how long one run has been running, not counting the time it was held still.

Source§

impl<This> SessionLaws<This> for This

Source§

fn session_laws(&mut self) -> Result<(), Error>

Checks that one pass reconciles what is wanted with what is happening.

The laws checked are:

  1. one pass begins every request wanting work, and no other;
  2. a request whose work has begun is not begun again, however many passes run;
  3. everything a run said is told before how it ended, and nothing is told after;
  4. work refusing to begin ends once and is not begun again;
  5. a run nobody wants is told to end on every pass until it is over, and ends once;
  6. time a run is held still is not counted as time it was running;
  7. attending to no runs tells nothing.
§Errors

Returns the first violated law.

Source§

fn check_beginning_laws(&mut self) -> Result<(), Error>

Checks what one pass begins, and what it declines to begin twice.

§Errors

Returns the first violated law.

Source§

fn check_saying_laws(&mut self) -> Result<(), Error>

Checks that what a run said reaches the request before how it ended.

§Errors

Returns the first violated law.

Source§

fn check_unwanted_laws(&mut self) -> Result<(), Error>

Checks how a run nobody wants any more is ended.

§Errors

Returns the first violated law.

Source§

fn check_holding_laws(&mut self) -> Result<(), Error>

Checks that time a run is held still is not time it was running.

§Errors

Returns the first violated law.

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.