Skip to main content

Crate taao

Crate taao 

Source
Expand description

Run futures on a Tao or winit event-loop thread.

taao bridges the Tao or winit event loop and async Rust: it drives the event loop on the current thread while polling a future, and notifies the event-loop thread through the event-loop proxy whenever the future is woken.

Exactly one backend feature must be enabled: tao (default) or winit.

§Running a future

Call EventLoopBlockOn::block_on on the backend event loop; it returns the future’s output once the future completes:

use taao::EventLoopBlockOn;

let mut event_loop = tao::event_loop::EventLoop::new();
let answer = event_loop.block_on(async { 42 })?;
assert_eq!(answer, 42);

With the winit feature, the same call works on the winit event loop.

§Events and event-loop operations

With the event feature, EventLoopBlockOn::block_on_with_events additionally hands the future an event::Event: a stream of backend events plus event::Submitter::submit for running closures on the event-loop thread. Use event::Event::submitter to get a cloneable handle for submitting from separate tasks. Import taao::event::Submitter to call .submit(...) on either handle. See the event module.

§Features

FeatureDescriptionDefault
taoUse the Tao backendYes
winitUse the winit backendNo
eventEnable the event stream and Submitter::submitNo
tracingEnable diagnostic loggingNo

Modules§

eventevent
Event streams and event-loop operations, available with the event feature.

Enums§

BlockOnError
Error returned when driving a future on the event-loop thread fails.

Traits§

EventLoopBlockOntao and non-iOS, or winit and neither iOS nor WebAssembly
Extension trait that runs a future to completion on the backend’s event-loop thread.