Skip to main content

View

Trait View 

Source
pub trait View<State>: 'static
where State: 'static,
{ type Element: Widget; // Required methods fn build(&self, ctx: &mut BuildCtx<'_>) -> Self::Element; fn rebuild( &self, prev: &Self, element: &mut Self::Element, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags; // Provided methods fn teardown(&self, _element: &mut Self::Element, _ctx: &mut BuildCtx<'_>) { ... } fn message(&self, _element: &mut Self::Element, _state: &mut State) { ... } }
Expand description

A declarative description of a piece of UI.

Each View knows how to materialise itself into a retained Widget (View::build) and how to reconcile a previous version of itself against the live widget (View::rebuild). State is 'static so views never capture borrowed data — they are values, re-created every frame.

Required Associated Types§

Source

type Element: Widget

The retained widget this view produces.

Required Methods§

Source

fn build(&self, ctx: &mut BuildCtx<'_>) -> Self::Element

Materialise a fresh widget for this view.

Source

fn rebuild( &self, prev: &Self, element: &mut Self::Element, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags

Reconcile prev (the previous view of the same type) against the live element, mutating it in place and reporting what changed.

Provided Methods§

Source

fn teardown(&self, _element: &mut Self::Element, _ctx: &mut BuildCtx<'_>)

Tear down element when this view is being removed.

A no-op for v0 leaf views; kept in the trait so the lifecycle is complete and container/removal logic (later phases) has a hook.

Source

fn message(&self, _element: &mut Self::Element, _state: &mut State)

Deliver an event message to this view, mutating application state.

Stubbed for v0 (no event routing yet); present so the trait shape is stable as event routing is added later.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<State> View<State> for PinchDetectorView<State>
where State: 'static,

Source§

type Element = PinchDetectorWidget

Source§

fn build(&self, ctx: &mut BuildCtx<'_>) -> PinchDetectorWidget

Source§

fn rebuild( &self, prev: &PinchDetectorView<State>, element: &mut PinchDetectorWidget, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags

Source§

fn teardown(&self, element: &mut PinchDetectorWidget, ctx: &mut BuildCtx<'_>)

Implementors§

Source§

impl<Outer, C> View<Outer> for ComponentView<C>
where Outer: 'static, C: Component,

Source§

impl<State, P> View<State> for PatternSwitcherView<State, P>
where State: 'static, P: TransitionPattern + Clone + 'static,

Source§

impl<State> View<State> for AlignView<State>
where State: 'static,

Source§

impl<State> View<State> for AnimatedOpacityView<State>
where State: 'static,

Source§

impl<State> View<State> for AnimatedScaleView<State>
where State: 'static,

Source§

impl<State> View<State> for AnyView<State>
where State: 'static,

Source§

impl<State> View<State> for ButtonView<State>
where State: 'static,

Source§

impl<State> View<State> for CanvasView<State>
where State: 'static,

Source§

impl<State> View<State> for CheckboxView<State>
where State: 'static,

Source§

impl<State> View<State> for ContainerView<State>
where State: 'static,

Source§

impl<State> View<State> for DividerView
where State: 'static,

Source§

impl<State> View<State> for FlexView<State>
where State: 'static,

Source§

impl<State> View<State> for GestureDetectorView<State>
where State: 'static,

Source§

impl<State> View<State> for HeroView<State>
where State: 'static,

Source§

impl<State> View<State> for IconButtonView<State>
where State: 'static,

Source§

impl<State> View<State> for IconView
where State: 'static,

Source§

impl<State> View<State> for ImageView
where State: 'static,

Source§

impl<State> View<State> for ListView<State>
where State: 'static,

Source§

impl<State> View<State> for NavigatorView<State>
where State: 'static,

Source§

impl<State> View<State> for OverlayPortalView<State>
where State: 'static,

Source§

impl<State> View<State> for PaddingView<State>
where State: 'static,

Source§

impl<State> View<State> for PanZoomView<State>
where State: 'static,

Source§

impl<State> View<State> for PlatformViewView
where State: 'static,

Source§

impl<State> View<State> for RadioView<State>
where State: 'static,

Source§

impl<State> View<State> for SafeAreaView<State>
where State: 'static,

Source§

impl<State> View<State> for ScaffoldView<State>
where State: 'static,

Source§

impl<State> View<State> for ScrollView<State>
where State: 'static,

Source§

impl<State> View<State> for ShieldView<State>
where State: 'static,

Source§

impl<State> View<State> for SizedBoxView<State>
where State: 'static,

Source§

impl<State> View<State> for SliderView<State>
where State: 'static,

Source§

impl<State> View<State> for StackView<State>
where State: 'static,

Source§

impl<State> View<State> for TextInputView<State>
where State: 'static,

Source§

impl<State> View<State> for TextView
where State: 'static,