SchedulerExtensions
trait · ferroui-reactiveui-testing · v0.5.0
trait SchedulerExtensions
Runs code with a scheduler as both schedulers of RxSchedulers, the main thread scheduler
and the task pool scheduler (SchedulerExtensions).
It is implemented for a scheduler handle (Rc<dyn IScheduler>, Rc<S>) and for the
TestScheduler of ferroui-reactive-testing; the block receives the scheduler it was called
on.
Deviation (DEVIATIONS.md, ReactiveUI): the schedulers of RxSchedulers are per thread, so the
scheduler is the scheduler of the current thread only.
Members
as_scheduler
fn as_scheduler(self: &Self) -> Rc<dyn IScheduler>
The scheduler as the handle that RxSchedulers holds.
with_scheduler
fn with_scheduler(self: &Self) -> Rc<dyn IDisposable>
Makes the scheduler both schedulers of RxSchedulers until the returned disposable is
disposed, which restores the schedulers set before (WithScheduler).
with
fn with<R>(self: &Self, block: impl FnOnce(&Self) -> R) -> R
Runs block with the scheduler as both schedulers of RxSchedulers and returns its
result; the schedulers set before are restored afterwards, also when block panics
(With<TRet>(Func<T, TRet>), and With(Action<T>) with a block that returns ()).
with_async
fn with_async<R: Clone + 'static, Fut: Future<Output = Result<R, ObservableError>> + 'static>(self: &Self, block: impl FnOnce(&Self) -> Fut) -> Shared<Result<R, ObservableError>>
Runs block with the scheduler as both schedulers of RxSchedulers until the task it
returns ends, and gives the outcome of that task (WithAsync<TRet>(Func<T, Task<TRet>>),
and WithAsync(Func<T, Task>) with R = ()): the block gives a future of a
Result<R, ObservableError>, which runs as a task of the thread, and the task is the
Shared of its result.
A panic of block ends the returned task with the error of the panic
(PanicError), as an exception thrown in an async method faults its task; the
schedulers are restored in every case.
Trait implementations
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.