ratatui_kit/element/
element_ext.rs

1use 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 {
23    fn key(&self) -> &ElementKey;
24    fn props_mut(&mut self) -> AnyProps;
25    fn helper(&self) -> Box<dyn ComponentHelperExt>;
26    fn render_loop(&mut self, options: TerminalOptions) -> impl Future<Output = io::Result<()>>;
27    fn fullscreen(&mut self) -> impl Future<Output = io::Result<()>>;
28}