ratatui_kit/element/
element_ext.rs

1use super::ElementKey;
2use crate::{component::ComponentHelperExt, props::AnyProps};
3use std::io;
4
5mod private {
6    use crate::{
7        component::Component,
8        element::{AnyElement, Element},
9    };
10
11    pub trait Sealed {}
12
13    impl<'a> Sealed for AnyElement<'a> {}
14    impl<'a> Sealed for &mut AnyElement<'a> {}
15
16    impl<'a, T> Sealed for Element<'a, T> where T: Component {}
17    impl<'a, T> Sealed for &mut Element<'a, T> where T: Component {}
18}
19
20pub trait ElementExt: private::Sealed + Sized {
21    fn key(&self) -> &ElementKey;
22    fn props_mut(&mut self) -> AnyProps;
23    fn helper(&self) -> Box<dyn ComponentHelperExt>;
24    fn render(&mut self) -> io::Result<()>;
25    fn render_loop(&mut self) -> impl Future<Output = io::Result<()>>;
26    fn fullscreen(&mut self) -> impl Future<Output = io::Result<()>>;
27}