Struct Session
pub struct Session {
pub controller: Controller,
pub pace: Pace,
pub reduced_motion: bool,
pub brush: Brush,
pub view: View,
/* private fields */
}Expand description
The controller plus everything a frame needs to present it.
Fields§
§controller: ControllerThe run being shown.
pace: PaceHow quickly a running study advances.
reduced_motion: boolWhether to skip decorative animation (prefers-reduced-motion).
brush: BrushThe drawing tool, active while the custom function runs.
view: ViewWhat the canvas shows besides the function.
Implementations§
§impl Session
impl Session
pub fn new(controller: Controller, pace: Pace, reduced_motion: bool) -> Self
pub fn new(controller: Controller, pace: Pace, reduced_motion: bool) -> Self
Wraps a controller. The custom function starts as the controller’s, if it runs one, else as the default formula.
pub fn notice(&self) -> Option<&str>
pub fn notice(&self) -> Option<&str>
Why the last stroke was refused, until the next change of the custom function.
pub const fn edits(&self) -> u64
pub const fn edits(&self) -> u64
Increments whenever Self::custom or Self::notice changes, so
the page refreshes its formula field only then.
pub fn model_points(&self) -> Option<usize>
pub fn model_points(&self) -> Option<usize>
How many completed trials the model map on screen was fitted to:
Some(0) while too few trials have completed for a model, None
while the map is off or not yet computed for this run.
pub fn set_model_service(&mut self, service: Box<dyn ModelService>)
pub fn set_model_service(&mut self, service: Box<dyn ModelService>)
Injects the browser’s optional off-thread model executor.
pub fn model_source(&self) -> &'static str
pub fn model_source(&self) -> &'static str
Where the model fit, raster samples and hover readings are computed.
pub const fn model_reading(&self) -> Option<(f64, f64)>
pub const fn model_reading(&self) -> Option<(f64, f64)>
The model’s mean and standard deviation in the hover reading the model
panel last drew: None while the pointer is elsewhere or the exact
answer is still pending.
pub fn refuse(&mut self, message: String)
pub fn refuse(&mut self, message: String)
Records why a custom function was refused, for the page to show.
pub fn set_custom(&mut self, landscape: Landscape) -> Result<()>
pub fn set_custom(&mut self, landscape: Landscape) -> Result<()>
Makes landscape the custom function and runs it, under the current
sampler and scheduler, from a reset.
§Errors
The study could not be created.
pub fn run_custom(&mut self) -> Result<()>
pub fn run_custom(&mut self) -> Result<()>
pub fn advance(&mut self, now: f64) -> Option<f64>
pub fn advance(&mut self, now: f64) -> Option<f64>
Advances a running study if its pace allows a trial at time now
(seconds); see Self::advance_timed. Without a clock, the
Pace::Max slice never runs out, so one call finishes the run.
pub fn advance_timed(
&mut self,
now: f64,
clock: &dyn Fn() -> f64,
) -> Option<f64>
pub fn advance_timed( &mut self, now: f64, clock: &dyn Fn() -> f64, ) -> Option<f64>
Advances a running study by one transaction if its pace allows one at
time now (seconds), and at Pace::Max by more whole transactions
while clock (seconds) stays within the pace’s frame slice. Returns how
long to wait before the next frame should run, or None when nothing
is scheduled.
pub fn show(&mut self, ui: &mut Ui) -> bool
pub fn show(&mut self, ui: &mut Ui) -> bool
Paints every panel into the remaining space of ui, computing an
inline model map (and a learner’s whole heatmap) at once. A model
service, when injected, still runs asynchronously. Returns
whether the canvas wants another frame (an animation, or a map in
progress).
pub fn show_timed(&mut self, ui: &mut Ui, clock: &dyn Fn() -> f64) -> bool
pub fn show_timed(&mut self, ui: &mut Ui, clock: &dyn Fn() -> f64) -> bool
Self::show, sampling a learner’s heatmap only while clock
(seconds) stays within LANDSCAPE_SLICE of the frame’s start and
sampling inline model rows within MODEL_SLICE after that. An
injected service computes the fit and samples off-thread instead.
pub const fn landscape_seconds(&self) -> Option<f64>
pub const fn landscape_seconds(&self) -> Option<f64>
How long, by the frames’ clock, this session spent sampling the
learner’s heatmap it finished: one fixed-seed training run per cell.
None until it finishes one (or when the process had one cached).
pub fn landscape_progress(&self) -> Option<(usize, usize)>
pub fn landscape_progress(&self) -> Option<(usize, usize)>
The landscape still being sampled, as (done, total) cells, while a
learner’s heatmap is in progress.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Session
impl !RefUnwindSafe for Session
impl !Send for Session
impl !Sync for Session
impl !UnwindSafe for Session
impl Unpin for Session
impl UnsafeUnpin for Session
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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, U> Imply<T> for U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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