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§
Sourcefn spawn<F, T>(&self, f: F) -> impl Future<Output = T>
fn spawn<F, T>(&self, f: F) -> impl Future<Output = T>
Run an arbitrary closure on the main thread and resolve to its result.
Sourcefn create_surface(
&self,
desc: SurfaceDesc,
) -> Pin<Box<dyn Future<Output = Surface> + Send>>
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".