Skip to main content

MainThreadSpawner

Trait MainThreadSpawner 

Source
pub trait MainThreadSpawner:
    Send
    + Sync
    + 'static {
    // Required methods
    fn spawn<F, T>(&self, f: F) -> impl Future<Output = T>
       where F: FnOnce() -> T + Send + 'static,
             T: Send + 'static;
    fn create_surface(
        &self,
        desc: SurfaceDesc,
    ) -> Pin<Box<dyn Future<Output = Surface> + Send>>;
}
Expand description

Runs main-thread-only operations, as required by some operating systems (e.g. macOS). On platforms without that requirement the implementation may run them in place.

Required Methods§

Source

fn spawn<F, T>(&self, f: F) -> impl Future<Output = T>
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,

Run an arbitrary closure on the main thread and resolve to its result.

Source

fn create_surface( &self, desc: SurfaceDesc, ) -> Pin<Box<dyn Future<Output = Surface> + Send>>

Create a surface (window) on the main thread.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§