1use crate::{Devtools, DomEvent, Viewport, WasmNotSendSync};
2use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
3use std::any::Any;
4use std::sync::Arc;
5
6pub trait Document: AsRef<Self::Doc> + AsMut<Self::Doc> + Into<Self::Doc> + 'static {
7 type Doc: 'static;
8
9 fn poll(&mut self, _cx: std::task::Context) -> bool {
10 false
12 }
13
14 fn handle_event(&mut self, _event: &mut DomEvent) {
15 }
17
18 fn as_any_mut(&mut self) -> &mut dyn Any {
19 self
20 }
21
22 fn id(&self) -> usize;
23}
24
25pub trait BlitzWindowHandle: HasWindowHandle + HasDisplayHandle + WasmNotSendSync {}
26impl<T: HasWindowHandle + HasDisplayHandle + WasmNotSendSync> BlitzWindowHandle for T {}
27
28pub trait DocumentRenderer {
29 type Doc: 'static;
30
31 fn new(window: Arc<dyn BlitzWindowHandle>) -> Self;
32 fn is_active(&self) -> bool;
33 fn resume(&mut self, viewport: &Viewport);
34 fn suspend(&mut self);
35
36 fn set_size(&mut self, physical_width: u32, physical_height: u32);
38
39 fn render(&mut self, doc: &Self::Doc, scale: f64, width: u32, height: u32, devtools: Devtools);
40}