Crate waterui_core

Crate waterui_core 

Source
Expand description

§WaterUI Core

waterui_core provides the essential building blocks for developing cross-platform reactive UIs. This foundation layer establishes a unified architecture that works consistently across desktop, mobile, web, and embedded environments.

§Architecture Overview

The system is structured around these key concepts:

§Declarative View System

The View trait forms the foundation of the UI component model:

pub trait View: 'static {
    fn body(self, env: &Environment) -> impl View;
}

This recursive definition enables composition of complex interfaces from simple building blocks. Each view receives contextual information and transforms into its visual representation.

§Context Propagation

The Environment provides a type-based dependency injection system:

use waterui_core::Environment;

let env = Environment::new();
// .with() and .install() methods would be used with actual theme and plugin types

This propagates configuration and resources through the view hierarchy without explicit parameter passing.

§Type Erasure

AnyView enables heterogeneous collections by preserving behavior while erasing concrete types, facilitating dynamic composition patterns.

§Component Architecture

The framework provides several component categories:

  • Platform Components: Native UI elements with platform-optimized rendering
  • Reactive Components: Views that automatically update when data changes
  • Metadata Components: Elements that carry additional rendering instructions
  • Composite Components: Higher-order components built from primitive elements

§Reactive Data Flow

State management integrates seamlessly with the view system:

use waterui_core::{Dynamic, binding, Binding};

// Create a reactive state container
let counter: Binding<i32> = binding(0);

// Create a view that responds to state changes using Dynamic
let view = Dynamic::watch(counter, |count: i32| {
     format!("Current value: {}", count)
});

The UI automatically updates when state changes, with efficient rendering that only updates affected components.

§Extensibility

The plugin interface enables framework extensions without modifying core code:

use waterui_core::{plugin::Plugin, Environment};

struct MyPlugin;
impl Plugin for MyPlugin {}

let mut env = Environment::new();
MyPlugin.install(&mut env);

This enables modular functionality like theming, localization, and platform-specific features.

Re-exports§

pub use env::Environment;
pub use view::View;
pub use animation::AnimationExt;
pub use nami as reactive;

Modules§

animation
WaterUI Animation System
anyview
This module provides type-erased view implementations to enable heterogeneous collections of views and dynamic dispatch.
binding
Reactive Bindings
constant
Constant Values for Reactive Computation
dynamic
Dynamic views that can be updated at runtime.
env
Environment management module for sharing data across views.
event
Event handling components and utilities.
extract
This module provides mechanisms for extracting values from the Environment.
handler
Handler traits and implementations for processing environments.
id
Identity, tagging, and mapping functionality for UI components.
layout
Layout primitives and geometry types for the WaterUI layout system.
metadata
Metadata components for attaching arbitrary data to views.
native
This module provides platform-specific native views that can wrap platform-native UI components.
plugin
Provides the Plugin trait for extending application functionality.
resolve
Module for resolving reactive values in different environments.
view
View Module
views
Collection of view-related utilities for managing and transforming UI components.

Macros§

configurable
Creates a configurable view with builder pattern methods.
impl_debug
Implements a basic Debug trait for types using their type name.
impl_deref
Implements the Deref trait for transparent access to an inner type.
impl_extractor
Implements the Extractor trait for a type.
raw_view
Implements a native view that is handled by the platform backend.

Structs§

AnyView
A type-erased wrapper for a View.
Binding
A Binding<T> represents a mutable value of type T that can be observed.
Computed
A wrapper around a boxed implementation of the ComputedImpl trait.
Dynamic
A dynamic view that can be updated.
Error
The Error type, a wrapper around a dynamic error type.
IgnorableMetadata
A metadata wrapper that can be safely ignored by renderers if not handled explicitly.
Metadata
Represents a view that carries additional metadata of type T.
Native
A wrapper for platform-specific native UI components.
Retain
A metadata key that retains a value for its lifetime.
Str
A string type that can be either a static reference or a ref-counted owned string.
With
A wrapper allows a view to carry an additional value without affecting its rendering.

Traits§

NativeView
A trait for all views handled by the native backend.
Signal
The core trait for reactive system.
SignalExt
Extension trait providing convenient methods for all Signal types.

Functions§

binding
Creates a new binding from a value with automatic type conversion.
constant
Creates a new constant reactive value.