pub struct TestScheduler { /* private fields */ }Expand description
Virtual-time scheduler. Time only advances when advance_by /
advance_to is called.
Implementations§
Source§impl TestScheduler
impl TestScheduler
pub fn new() -> Self
Sourcepub fn schedule_after<F>(&self, delay: Duration, cb: F) -> ScheduledToken
pub fn schedule_after<F>(&self, delay: Duration, cb: F) -> ScheduledToken
Schedule cb to fire delay after the current virtual time.
Sourcepub fn cancel(&self, token: ScheduledToken) -> bool
pub fn cancel(&self, token: ScheduledToken) -> bool
Cancel a scheduled callback if it hasn’t fired or been
cancelled yet. Returns true iff this call performed the
cancellation; subsequent cancels of the same token are no-ops
returning false.
Sourcepub async fn advance_by(&self, delta: Duration)
pub async fn advance_by(&self, delta: Duration)
Advance virtual time by delta, firing all callbacks whose
fire-at falls in the new range. Callbacks fire in fire-at order.
Sourcepub async fn advance_to(&self, target: Instant)
pub async fn advance_to(&self, target: Instant)
Advance virtual time to target (must be ≥ current time).
Sourcepub fn fired(&self, token: ScheduledToken) -> bool
pub fn fired(&self, token: ScheduledToken) -> bool
Has the scheduled callback fired?
Trait Implementations§
Source§impl Clone for TestScheduler
impl Clone for TestScheduler
Source§fn clone(&self) -> TestScheduler
fn clone(&self) -> TestScheduler
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TestScheduler
impl RefUnwindSafe for TestScheduler
impl Send for TestScheduler
impl Sync for TestScheduler
impl Unpin for TestScheduler
impl UnsafeUnpin for TestScheduler
impl UnwindSafe for TestScheduler
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
Mutably borrows from an owned value. Read more