use std::fmt::Debug;
use async_trait::async_trait;
use r3bl_rs_utils_core::*;
use crate::*;
#[async_trait]
pub trait Component<S, A>
where
S: Debug + Default + Clone + PartialEq + Sync + Send,
A: Debug + Default + Clone + Sync + Send,
{
fn reset(&mut self);
fn get_id(&self) -> FlexBoxId;
async fn render(
&mut self,
args: ComponentScopeArgs<'_, S, A>,
current_box: &FlexBox,
surface_bounds: SurfaceBounds,
) -> CommonResult<RenderPipeline>;
async fn handle_event(
&mut self,
args: ComponentScopeArgs<'_, S, A>,
input_event: &InputEvent,
) -> CommonResult<EventPropagation>;
}
#[async_trait]
pub trait SurfaceRender<S, A>
where
S: Debug + Default + Clone + PartialEq + Sync + Send,
A: Debug + Default + Clone + Sync + Send,
{
async fn render_in_surface(
&mut self,
args: GlobalScopeArgs<'_, S, A>,
surface: &mut Surface,
) -> CommonResult<()>;
}