Skip to main content

ErrorBoundaryState

Struct ErrorBoundaryState 

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

ErrorBoundary 的 element state。

字段:

  • error:最近一次 descendant build panic 的消息;Some → build 输出 fallback
  • last_reset_key:上次见过的 reset_key(变化 → 清 error)

Implementations§

Source§

impl ErrorBoundaryState

Source

pub fn new() -> Self

Source

pub fn error(&self) -> Option<&str>

当前错误消息(None = 正常显示 child)

Trait Implementations§

Source§

impl Debug for ErrorBoundaryState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ErrorBoundaryState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl State for ErrorBoundaryState

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

必须显式实现(框架约定)
Source§

fn build(&self, _ctx: &mut BuildContext<'_>) -> Vec<WidgetNode>

build 阶段:从 ctx 取主题等,返回子节点列表(默认 widget().children())
Source§

fn create_render_object(&self) -> Box<dyn RenderObject>

创建 RenderObject —— 默认转发到 widget().create_render_object() (大多数 State 不需要自己实现,除非需要定制 RenderObject)
Source§

fn did_update_widget(&mut self)

widget 被替换(同类型复用)后调用;默认空实现。
Source§

fn handles_build_error(&self) -> bool

是否处理 build panic(ErrorBoundary 用)
Source§

fn on_build_error(&mut self, msg: &str)

build panic 时回调
Source§

fn as_any(&self) -> &dyn Any

类型擦除入口(只读)。
Source§

fn widget(&self) -> &WidgetNode

当前关联的 widget 节点(由框架在 mount/update 时写入)。
Source§

fn set_widget(&mut self, widget: WidgetNode)

框架在 widget 更新时调用,State 据此 adopt 新配置(保留自身字段)。
Source§

fn init_state(&mut self)

首次挂载、State 创建后调用一次。
Source§

fn dispose(&mut self)

Element 卸载时调用;释放订阅/定时器等资源。
Source§

fn apply_to_ro(&mut self, ro: &mut dyn RenderObject) -> StateApply

P0-1:尝试把当前 state 就地写回已有 RO。 Read more
Source§

fn semantics(&self) -> Option<WidgetSemantics>

State 侧语义覆盖:用于暴露静态 widget 无法提供的动态值 (例如 TextField 的当前文本)。None = 使用 widget.semantics()。
Source§

fn handle_event(&mut self, event: &WidgetEvent, local_pos: Point)

处理指针/键盘/IME 事件(local_pos 已折算到本 element 坐标系)。
Source§

fn handle_event_ctx( &mut self, event: &WidgetEvent, local_pos: Point, _ctx: &mut EventContext, )

带消费语义的事件处理;默认转发 Self::handle_event 并继续冒泡。
Source§

fn scroll_into_view(&mut self, _target: Rect) -> bool

无障碍 ScrollIntoView:把相对本元素左上角的 target 矩形滚动到可视区。 Read more
Source§

fn tick(&mut self, _now_ms: u64)

每帧 tick(长按计时器、动画控制器等需要时间的机制;now_ms = 当前时间戳毫秒)
Source§

fn handle_overlay_key(&mut self, _key: KeyCode, _mods: KeyModifiers) -> bool

覆盖层打开时的键盘导航钩子(方向键 / Home / End / Enter / Space)。 Read more
Source§

fn is_animating(&self) -> bool

ScrollView/ListView 特有:滚动动画中
Source§

fn next_animation_delay(&self, _now_ms: u64) -> Option<u64>

下一次需要 tick 的延迟(毫秒);None = 无定时任务。 Read more
Source§

fn take_needs_build(&mut self) -> bool

State 请求框架重建本 element 的 children(build + diff,与 update 同路径)。 Read more
Source§

fn gesture_state(&self) -> Option<GestureState>

竞技场仲裁:有持续型手势胜出 → 返回 Accepted 独占指针
Source§

fn reject_gestures(&mut self)

被竞争失败:放弃进行中的手势
Source§

fn ime_cursor_area(&self) -> Option<(f32, f32, f32)>

TextField/TextBox 用:IME 光标区域(x, y, line_height) — 多行感知
Source§

fn as_overlay_aware(&mut self) -> Option<&mut dyn OverlayAware>

Overlay-aware capability 探测 —— 返回 self 若实现了 OverlayAware trait,否则 None Read more

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.