Module task

Source
Expand description

Task related testing utilities.

This module provides utilities for creating test Contexts, Wakers and Spawn implementations.

Test contexts:

Test wakers:

Test spawners:

For convenience there additionally exist various functions that directly return waker/spawner references: noop_waker_ref, panic_waker_ref, noop_spawner_mut and panic_spawner_mut.

Structs§

AwokenCount
Number of times the waker was awoken.
NoopSpawner
An implementation of Spawn that discards spawned futures when used.
PanicSpawner
An implementation of Spawn that panics when used.
RecordSpawner
An implementation of Spawn that records any Futures spawned on it.

Functions§

new_count_waker
Create a new Waker that counts the number of times it’s awoken.
noop_context
Create a new Context where the waker will ignore any uses.
noop_spawner_mut
Get a reference to a singleton instance of NoopSpawner.
noop_waker
Create a new Waker which does nothing when wake() is called on it.
noop_waker_ref
Get a static reference to a Waker which does nothing when wake() is called on it.
panic_context
Create a new Context where the waker will panic if used.
panic_spawner_mut
Get a reference to a singleton instance of PanicSpawner.
panic_waker
Create a new Waker which will panic when wake() is called on it. The Waker can be converted into a Waker which will behave the same way.
panic_waker_ref
Get a global reference to a Waker referencing a singleton instance of a Waker which panics when woken.