pub struct Cassette<T>{ /* private fields */ }
Expand description
A single-future non-blocking executor
Implementations§
source§impl<T> Cassette<T>
impl<T> Cassette<T>
sourcepub fn new(thing: T) -> Self
pub fn new(thing: T) -> Self
Create a new Cassette containing a single pinned future
§Example
use cassette::Cassette;
struct Demo {
lol: u32,
}
impl Demo {
async fn entry(&mut self) {
/* Huzzah! */
}
}
// Make a new struct
let mut demo = Demo { lol: 100 };
// Call the entry point future, and pin it
let x = core::pin::pin!(demo.entry());
// Give the pinned future to Cassette
// for execution
let mut cm = Cassette::new(x);
sourcepub fn poll_on(&mut self) -> Option<<T as Future>::Output>
pub fn poll_on(&mut self) -> Option<<T as Future>::Output>
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::Cassette;
struct Demo {
lol: u32,
}
impl Demo {
async fn entry(&mut self) {
/* Huzzah! */
}
}
// Make a new struct
let mut demo = Demo { lol: 100 };
// Call the entry point future, and pin it
let x = core::pin::pin!(demo.entry());
// Give the pinned future to Cassette
// for execution
let mut cm = Cassette::new(x);
while cm.poll_on().is_none() { }
println!("Future done!");
§Panics
This method will panic if the contained future has already
been completed as Poll::Ready(_)
.
Auto Trait Implementations§
impl<T> Freeze for Cassette<T>where
T: Freeze,
impl<T> RefUnwindSafe for Cassette<T>where
T: RefUnwindSafe,
impl<T> Send for Cassette<T>where
T: Send,
impl<T> Sync for Cassette<T>where
T: Sync,
impl<T> Unpin for Cassette<T>
impl<T> UnwindSafe for Cassette<T>where
T: UnwindSafe,
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