Skip to main content

ElementExt

Trait ElementExt 

Source
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§

Source

fn key(&self) -> &ElementKey

获取元素的唯一 key,适合 diff、重用等场景。

Source

fn props_mut(&mut self) -> AnyProps<'_>

获取并可变修改元素的属性(props)。

Source

fn helper(&self) -> Box<dyn ComponentHelperExt>

获取组件辅助操作对象,支持动态调度和扩展。

Source

fn render_loop( &mut self, options: TerminalOptions, ) -> impl Future<Output = Result<()>>

启动渲染主循环,传入终端选项,适合自定义Viewport场景。

Source

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".

Implementors§

Source§

impl<'a, T> ElementExt for &mut Element<'a, T>
where T: Component,

Source§

impl<'a, T> ElementExt for Element<'a, T>
where T: Component,

Source§

impl<'a> ElementExt for &mut AnyElement<'a>

Source§

impl<'a> ElementExt for AnyElement<'a>