pub trait WindowRenderer: RenderContext {
type ScenePainter<'a>: PaintScene
where Self: 'a;
// Required methods
fn resume<F: FnOnce() + 'static>(
&mut self,
window: Arc<dyn WindowHandle>,
width: u32,
height: u32,
on_ready: F,
);
fn complete_resume(&mut self) -> bool;
fn suspend(&mut self);
fn is_active(&self) -> bool;
fn set_size(&mut self, width: u32, height: u32);
fn render<F: FnOnce(&mut Self::ScenePainter<'_>)>(&mut self, draw_fn: F);
// Provided method
fn is_pending(&self) -> bool { ... }
}Expand description
Abstraction for rendering a scene to a window
Required Associated Types§
type ScenePainter<'a>: PaintScene where Self: 'a
Required Methods§
Sourcefn resume<F: FnOnce() + 'static>(
&mut self,
window: Arc<dyn WindowHandle>,
width: u32,
height: u32,
on_ready: F,
)
fn resume<F: FnOnce() + 'static>( &mut self, window: Arc<dyn WindowHandle>, width: u32, height: u32, on_ready: F, )
Begin resuming the renderer. on_ready fires when initialization completes —
synchronously inside resume on native, asynchronously (via
wasm_bindgen_futures::spawn_local) on wasm32-unknown-unknown. After it
fires, the embedder must call complete_resume to
transition the renderer to the active state.
Sourcefn complete_resume(&mut self) -> bool
fn complete_resume(&mut self) -> bool
Finalize a previously-initiated resume. Returns true once the renderer is
active and ready to render. Idempotent on already-active renderers; returns
false if a pending init has not yet produced a result.
Backends whose resume finishes synchronously inline should return true
directly. There is intentionally no default: forgetting to override this on
an async-init backend would silently no-op rendering.
fn suspend(&mut self)
fn is_active(&self) -> bool
fn set_size(&mut self, width: u32, height: u32)
fn render<F: FnOnce(&mut Self::ScenePainter<'_>)>(&mut self, draw_fn: F)
Provided Methods§
Sourcefn is_pending(&self) -> bool
fn is_pending(&self) -> bool
Returns true while an asynchronous resume is in flight (after resume
but before complete_resume has succeeded). Defaults to false for
backends with synchronous initialization.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".