Skip to main content

Element

Struct Element 

Source
pub struct Element { /* private fields */ }
Expand description

Element — 树上的一个节点

字段仅在 crate 内可写;外部通过只读 accessor(Element::id / Element::children / Element::render_object 等)查询,避免绕过 Element/RO 双树不变量直接改树。

Implementations§

Source§

impl Element

Source

pub fn id(&self) -> ElementId

Element 在树中的稳定 id。

Source

pub fn parent(&self) -> Option<ElementId>

父 element(root 为 None)。

Source

pub fn children(&self) -> &[ElementId]

直接子 element id 列表(顺序 = widget children 顺序)。

Source

pub fn widget(&self) -> &WidgetNode

当前关联的 widget 配置。

Source

pub fn render_object(&self) -> &SharedRO

Element 持有的共享 RenderObject。

Source

pub fn is_active(&self) -> bool

是否在活动树中(false = 已停放到 Inactive 池)。

Source

pub fn is_dirty(&self) -> bool

是否被标记为需要重画。

Source

pub fn state(&self) -> Option<&dyn State>

State(仅 StatefulWidget 才有)。

Source

pub fn state_mut(&mut self) -> Option<&mut dyn State>

可变 State(仅供 devtools / 测试模拟状态变更;框架内部走 State 生命周期)。

Source

pub fn state_box_mut(&mut self) -> Option<&mut Box<dyn State>>

可变 State Box(兼容测试直接 downcast_mut 的用法)。

Source

pub fn layer(&self) -> Option<LayerId>

所属 layer(None = root layer)。

Source

pub fn layout_offset(&self) -> Point

本 element 在所属 layer 内的布局偏移。

Source

pub fn is_inherited(&self) -> bool

是否是 InheritedWidget 节点。

Source

pub fn subscriber_id(&self) -> SubscriberId

响应式订阅者 id。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.