ratatui_kit/element/
element_ext.rs1use ratatui::TerminalOptions;
2
3use super::ElementKey;
4use crate::{component::ComponentHelperExt, props::AnyProps};
5use std::io;
6
7mod private {
8 use crate::{
9 component::Component,
10 element::{AnyElement, Element},
11 };
12
13 pub trait Sealed {}
14
15 impl<'a> Sealed for AnyElement<'a> {}
16 impl<'a> Sealed for &mut AnyElement<'a> {}
17
18 impl<'a, T> Sealed for Element<'a, T> where T: Component {}
19 impl<'a, T> Sealed for &mut Element<'a, T> where T: Component {}
20}
21
22pub trait ElementExt: private::Sealed + Sized {
32 fn key(&self) -> &ElementKey;
34 fn props_mut(&mut self) -> AnyProps;
36 fn helper(&self) -> Box<dyn ComponentHelperExt>;
38 fn render_loop(&mut self, options: TerminalOptions) -> impl Future<Output = io::Result<()>>;
40 fn fullscreen(&mut self) -> impl Future<Output = io::Result<()>>;
42}