Skip to main content

Session

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: Controller

The run being shown.

§pace: Pace

How quickly a running study advances.

§reduced_motion: bool

Whether to skip decorative animation (prefers-reduced-motion).

§brush: Brush

The drawing tool, active while the custom function runs.

§view: View

What the canvas shows besides the function.

Implementations§

§

impl Session

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 custom(&self) -> &Arc<Landscape> ⓘ

The custom function, kept while a built-in one runs.

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

Increments whenever Self::custom or Self::notice changes, so the page refreshes its formula field only then.

pub const fn painted(&self) -> &Painted

Where the last frame painted each panel.

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>)

Injects the browser’s optional off-thread model executor.

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)>

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)

Records why a custom function was refused, for the page to show.

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<()>

Switches the run to the custom function and resets it.

§Errors

The study could not be created.

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>

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

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

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>

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)>

The landscape still being sampled, as (done, total) cells, while a learner’s heatmap is in progress.

Trait Implementations§

§

impl Debug for Session

§

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

Formats the value using the given formatter. 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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

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,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

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.

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
§

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

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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