Struct wookie::Wookie [−][src]
pub struct Wookie<F> { /* fields omitted */ }
Expand description
A single-future stepping executor for test suites that tracks wakers.
Examples
use core::task::Poll;
use wookie::wookie;
wookie!(future: async { true });
assert_eq!(future.poll(), Poll::Ready(true));
// you can also just give a variable name if you have one:
let future = async { true };
wookie!(future);
assert_eq!(future.poll(), Poll::Ready(true));
// we can find out about the state of wakers any time:
assert_eq!(future.cloned(), 0);
assert_eq!(future.dropped(), 0);
assert_eq!(future.woken(), 0);
// or equivalently...
future.stats().assert(0, 0, 0);
Implementations
Creates a new Wookie
without pinning it to the stack. You
probably want the crate::wookie!
macro.
Returns how many times the waker has been woken. This count is cumulative, it is never reset and is allowed to overflow.
Returns how many times the waker has been cloned. This count is cumulative, it is never reset and is allowed to overflow.
Returns how many times a clone of the waker has been dropped. This count is cumulative, it is never reset and is allowed to overflow.
Returns how many times a clone of the waker has been dropped. This count is cumulative, it is never reset and is allowed to overflow.
Polls the contained future once.
Example
use core::task::Poll;
use wookie::wookie;
wookie!(future: async { true });
assert_eq!(future.poll(), Poll::Ready(true));
Polls the contained future until completion, so long as the previous poll caused one or more wakes.
Example
use core::task::Poll;
use wookie::wookie;
wookie!(future: async { true });
assert_eq!(future.poll_while_woken(), Poll::Ready(true));