use std::{fmt::{Debug, Display},
sync::Arc};
use async_trait::async_trait;
use r3bl_rs_utils_core::*;
use tokio::sync::RwLock;
use crate::*;
#[async_trait]
pub trait App<S, A>
where
S: Display + Default + Clone + PartialEq + Debug + Sync + Send,
A: Display + Default + Clone + Sync + Send,
{
async fn app_render(&mut self, args: GlobalScopeArgs<'_, S, A>) -> CommonResult<RenderPipeline>;
async fn app_handle_event(
&mut self,
args: GlobalScopeArgs<'_, S, A>,
window_size: Size,
input_event: &InputEvent,
) -> CommonResult<EventPropagation>;
fn new_owned() -> BoxedSafeApp<S, A>
where
Self: Default + Sync + Send + 'static,
{
Box::new(Self::default())
}
fn new_shared() -> SharedApp<S, A>
where
Self: Default + Sync + Send + 'static,
{
Arc::new(RwLock::new(Self::default()))
}
}