pub trait ElementExt: Sealed + Sized {
// Required methods
fn key(&self) -> &ElementKey;
fn props_mut(&mut self) -> AnyProps<'_>;
fn helper(&self) -> Box<dyn ComponentHelperExt>;
fn render_loop(
&mut self,
options: TerminalOptions,
) -> impl Future<Output = Result<()>>;
fn fullscreen(&mut self) -> impl Future<Output = Result<()>>;
}Expand description
ElementExt trait 为所有 UI 元素提供统一的扩展方法。
支持获取/修改 key、props,辅助渲染,启动主循环、全屏渲染等。 适用于组件树的统一操作和终端 UI 应用的入口。
§常用用法
element!(MyComponent).fullscreen().await?;Required Methods§
Sourcefn key(&self) -> &ElementKey
fn key(&self) -> &ElementKey
获取元素的唯一 key,适合 diff、重用等场景。
Sourcefn render_loop(
&mut self,
options: TerminalOptions,
) -> impl Future<Output = Result<()>>
fn render_loop( &mut self, options: TerminalOptions, ) -> impl Future<Output = Result<()>>
启动渲染主循环,传入终端选项,适合自定义Viewport场景。
Sourcefn fullscreen(&mut self) -> impl Future<Output = Result<()>>
fn fullscreen(&mut self) -> impl Future<Output = Result<()>>
以全屏模式运行当前元素,适合大多数终端 UI 应用入口。
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.