use crate::core::{ImageOnHeap, Result, WindowId, WindowList};
pub struct Platform;
pub trait PlatformApiFactory {
fn setup() -> Result<Box<dyn PlatformApi>>;
}
pub trait PlatformApi: Send {
fn calibrate(&mut self, window_id: WindowId) -> Result<()>;
fn window_list(&self) -> Result<WindowList>;
fn capture_window_screenshot(&self, window_id: WindowId) -> Result<ImageOnHeap>;
fn get_active_window(&self) -> Result<WindowId>;
}
impl<T: PlatformApi + ?Sized> PlatformApi for Box<T> {
fn calibrate(&mut self, window_id: WindowId) -> Result<()> {
(**self).calibrate(window_id)
}
fn window_list(&self) -> Result<WindowList> {
(**self).window_list()
}
fn capture_window_screenshot(&self, window_id: WindowId) -> Result<ImageOnHeap> {
(**self).capture_window_screenshot(window_id)
}
fn get_active_window(&self) -> Result<WindowId> {
(**self).get_active_window()
}
}