Struct Coach
pub struct Coach<S>where
S: 'static,{ /* private fields */ }Expand description
The schedule of a set of hints over the signals S a host observes.
A host feeds it what the person did (Self::observe) and, every
frame, what holds and whether now is a quiet moment (Self::tick).
It answers which hint to show (Self::current) and what was learned
or shown that the person’s own record should keep (Self::learned).
Implementations§
§impl<S> Coach<S>
impl<S> Coach<S>
pub fn new(specs: &'static [HintSpec<S>], learned: Learned) -> Coach<S>
pub fn learned(&self) -> &Learned
pub fn learned(&self) -> &Learned
What the person’s record keeps: which hints are learned, how often each showed, and whether hints show at all.
pub fn take_changed(&mut self) -> Option<Learned>
pub fn take_changed(&mut self) -> Option<Learned>
The record, when it changed since the last call: the host writes it to the person’s own data.
pub fn merge(&mut self, other: &Learned, now: Instant)
pub fn merge(&mut self, other: &Learned, now: Instant)
Fold in the record as another device left it: a hint learned anywhere is learned here, and a hint on screen that the other device learned goes.
pub fn set_enabled(&mut self, enabled: bool, now: Instant)
pub fn set_enabled(&mut self, enabled: bool, now: Instant)
Turn hints on or off (the person’s one setting).
pub fn observe(&mut self, signal: S, now: Instant)
pub fn observe(&mut self, signal: S, now: Instant)
The person did signal. Every hint it teaches is learned, shown or
not: one on screen acknowledges it, one not yet shown never will.
A hint whose moment it is (Cue::Saw) remembers that.
pub fn tick(
&mut self,
now: Instant,
holds: &dyn Fn(S) -> bool,
quiet: Option<Quiet>,
anchored: &dyn Fn(usize) -> bool,
timing: Timing,
)
pub fn tick( &mut self, now: Instant, holds: &dyn Fn(S) -> bool, quiet: Option<Quiet>, anchored: &dyn Fn(usize) -> bool, timing: Timing, )
Advance to now. holds says whether a fact holds right now;
quiet is why no hint may begin now, if anything; anchored whether
the host can place a hint at all (its anchor is on screen); the
phases’ lengths come from timing.
pub fn next_change(&self, timing: Timing) -> Option<Instant>
pub fn next_change(&self, timing: Timing) -> Option<Instant>
When the schedule next changes on its own, for a host that sleeps
between frames: the hint on screen ending a phase, or a waiting
Cue::After coming due.
Auto Trait Implementations§
impl<S> Freeze for Coach<S>
impl<S> RefUnwindSafe for Coach<S>where
S: RefUnwindSafe,
impl<S> Send for Coach<S>where
S: Sync,
impl<S> Sync for Coach<S>where
S: Sync,
impl<S> Unpin for Coach<S>
impl<S> UnsafeUnpin for Coach<S>
impl<S> UnwindSafe for Coach<S>where
S: RefUnwindSafe,
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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