Struct cassette::Cassette [−][src]
A single-future non-blocking executor
Implementations
impl<T> Cassette<T> where
T: Future + Unpin,
[src]
impl<T> Cassette<T> where
T: Future + Unpin,
[src]pub fn new(thing: T) -> Self
[src]
Create a new Cassette containing a single pinned future
Example
use cassette::{pin_mut, Cassette}; struct Demo { lol: u32, } impl Demo { async fn entry(&mut self) { /* Huzzah! */ } } fn main() { // Make a new struct let mut demo = Demo { lol: 100 }; // Call the entry point future, and pin it let x = demo.entry(); pin_mut!(x); // Give the pinned future to Cassette // for execution let mut cm = Cassette::new(x); /* ... */ }
pub fn poll_on(&mut self) -> Option<<T as Future>::Output>
[src]
Perform a “single step” of the future contained by this Cassette.
This is intended to be “polled to completion”, which might be for forever.
Example
use cassette::{pin_mut, Cassette}; struct Demo { lol: u32, } impl Demo { async fn entry(&mut self) { /* Huzzah! */ } } fn main() { // Make a new struct let mut demo = Demo { lol: 100 }; // Call the entry point future, and pin it let x = demo.entry(); pin_mut!(x); // Give the pinned future to Cassette // for execution let mut cm = Cassette::new(x); while cm.poll_on().is_none() { } println!("Future done!"); }
pub fn block_on(self) -> <T as Future>::Output
[src]
Block on the contained future forever
Panics
This method will panic if the contained future has already
been completed as Poll::Ready(_)
.
pub fn is_done(&self) -> bool
[src]
Has the contained future resolved to Poll::Ready(_)
yet?