pub struct Observer {
pub row_started: Option<Box<RowFn>>,
pub row_ended: Option<Box<RowFn>>,
pub checkpoint: Option<Box<CheckpointFn>>,
}Expand description
The host’s three functions, which a sheet calls while the work runs.
Each is optional: a function the host did not set costs one test where it
would be called, and no call. These are the only functions of the host’s
that a sheet calls, besides its LogSink.
use std::time::Duration;
use flm_core::progress::Observer;
// A host with a clock of its own stamps the rows, and sets no checkpoint.
let clock = || Some(Duration::from_millis(0)); // the host's clock
let observer = Observer {
row_started: Some(Box::new(move |_row| clock())),
row_ended: Some(Box::new(move |_row| clock())),
..Observer::default()
};The contract of the three functions:
- They are called on the thread doing the work, possibly from several threads at once, and hold the work up until they return.
- They are called outside any lock of the sheet. Inside one, the host may
take a
Sheet::snapshotand may callSheet::cancel; a cancellation asked for insidecheckpointis seen by the question that follows it. - Each row that starts gives exactly one call of
row_startedand, when it ends, one call ofrow_ended. A row that is only declared, or that ends asRowState::NotRun, gives none. - No function is called when a count advances.
A host with one thread (the library run as WebAssembly) does its display
inside these functions: in checkpoint it reads its own clock and, when
enough time has passed, takes a snapshot and shows it, and it may decide
there to cancel.
Fields§
§row_started: Option<Box<RowFn>>A row has started. The time returned, if any, is stored on the row as the time it started: the time elapsed since an origin the host chooses.
row_ended: Option<Box<RowFn>>A row that had started has ended, as RowState::Finished or
RowState::Failed. The time returned, if any, is stored as the time
it ended.
checkpoint: Option<Box<CheckpointFn>>The work is about to ask whether the build is cancelled
(Scope::cancelled).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Observer
impl !UnwindSafe for Observer
impl Forget for Observer
impl Freeze for Observer
impl Move for Observer
impl Send for Observer
impl Sync for Observer
impl Unpin for Observer
impl UnsafeUnpin for Observerwhere
*const dyn Fn(&RowSnapshot) -> Option<Duration> + Send + Sync is !null: UnsafeUnpin,
PhantomData<dyn Fn(&RowSnapshot) -> Option<Duration> + Send + Sync>: UnsafeUnpin,
*const dyn Fn() + Send + Sync is !null: UnsafeUnpin,
PhantomData<dyn Fn() + Send + Sync>: UnsafeUnpin,
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
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