use std::marker::PhantomData;
use crate::runtime::Runtime;
use crate::window::{RuntimeWindow, Window, WindowCreator};
pub trait Application: Sized + Send + Sync {
fn initialize(&mut self) {}
fn should_exit(&mut self) -> bool {
Self::open_window_count() == 0
}
#[must_use]
fn open_window_count() -> usize {
RuntimeWindow::count()
}
}
pub struct SingleWindowApplication<T> {
phantom: PhantomData<T>,
}
impl<T> Application for SingleWindowApplication<T> where T: Window + WindowCreator + 'static {}
impl<T> SingleWindowApplication<T>
where
T: Window + WindowCreator + 'static,
{
pub fn run(window: T) -> ! {
let app = Self {
phantom: PhantomData::default(),
};
Runtime::new(app).run(window.get_window_builder(), window)
}
}