use { std::{ io::{Read, Seek}, rc::Rc, }, wgpu::{Instance, Surface}, }; pub trait File: Seek + Read {} impl File for std::fs::File {} impl File for std::io::Cursor> {} pub enum Event { MouseButtonPressed, OpenTestFile(Box), } #[derive(Debug, Clone, Copy)] pub struct Size2i { pub width: u32, pub height: u32, } pub trait FrameTimer { fn mark_frame_start(&mut self); fn get_frame_time_seconds(&self) -> f64; } #[allow(async_fn_in_trait)] // https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html#where-the-gaps-lie pub trait MvuApp { async fn init( &mut self, instance: &Instance, surface: Surface<'static>, new_size: Size2i, frame_timer: Box, ); async fn resize(&mut self, size: Size2i); async fn update(&self, model: Rc, event: Event) -> Rc; async fn view(&mut self, model: Rc) -> Result<(), Box>; }