Expand description
Xilem Core provides primitives which are used by Xilem (a cross-platform GUI toolkit) and Xilem Web (a web frontend framework). If you are using Xilem, its documentation will probably be more helpful for you.
Xilem apps will interact with some of the functions from this crate, in particular memoize.
Xilem apps which use custom widgets (and therefore must implement custom views), will implement the View trait.
If you wish to implement the Xilem pattern in a different domain (such as for a terminal user interface), this crate can be used to do so. Though, while Xilem Core should be able to support all kinds of domains, the crate prioritizes the ergonomics for users of Xilem.
§Hot reloading
Xilem Core does not currently include infrastructure to enable hot reloading, but this is planned. The current proposal would split the application into two processes:
- The app process, which contains the app state and create the views, which would be extremely lightweight and can be recompiled and restarted quickly.
- The display process, which contains the widgets and would be long-lived, updating to match the new state of the view tree provided by the app process.
§Quickstart
§no_std support
Xilem Core supports running with #![no_std], but does require alloc to be available.
Re-exports§
pub use anymore;
Modules§
Structs§
- Append
Vec - An append only
Vec. - DynMessage
- A simple dynamically typed message for the
Viewtrait. - Environment
- A store of values which are accessible throughout the view tree.
- Environment
Item - Fork
- The view for
fork. - Frozen
- This view can be used, when there’s no access to the
State, other than in event callbacks - Lens
- The View for
lens. - MapMessage
- View type for
map_messageandmap_action. Most users will want to usemap_action(the latter). - MapState
- The View for
map_state. - Memoize
- A view which supports Memoization.
- Message
Context - The
MessageContextis used inView::message. - Message
Proxy - A way to send a message of an expected type to a specific view.
- NoElement
- Element type for views which don’t impact the element tree.
- OnAction
With Context - The View type for
on_action_with_context. See its documentation for details. - Provides
- The View type for
provides. See its documentation for details. - Rebuild
- A message sent to Views to instruct them to rebuild themselves.
- RunOnce
- The view type for
run_once. - Send
Message - A dynamically typed message which can be sent between threads, for use in reporting the results of asynchronous computation.
- Slot
- ViewId
- An identifier used to differentiate between the direct children of a
View. - With
Context - The View type for
with_context. See its documentation for details. - Without
Elements - The
ViewSequenceforwithout_elements, see its documentation for more context.
Enums§
- Count
- Classes that a
ViewSequencecan be a member of, grouped based on the number of elements it is known to contain. - Message
Result - The possible outcomes from a
View::message - Proxy
Error - The potential error conditions from a
RawProxysending a message
Traits§
- AnyElement
- An element which can be used for an
AnyViewcontainingChild. - AnyView
- A view which can have any view type where the
View::Elementis compatible withElement. - Async
Ctx - A
Contextfor aViewimplementation which supports asynchronous message reporting. - Element
Splice - A temporary “splice” to add, update and delete in an (ordered) sequence of elements. It is mainly intended for view sequences.
- Orphan
View - This trait provides a way to add
Viewimplementations for types that would be restricted otherwise by the orphan rules. - Phantom
View - A
Viewwhich has no element type. - RawProxy
- A handle to a Xilem driver which can be used to queue a message for a View.
- Resource
- Marker trait for types usable as resources.
- Super
Element - This element type is a superset of
Child. - View
- A lightweight, short-lived representation of the state of a retained structure, usually a user interface node.
- View
Element - A type which can be used as the
Elementassociated type for aView. - View
Marker - A type which can be a
View. Imposes no requirements on the underlying type. Should be implemented alongside everyViewimplementation: - View
Path Tracker - A tracker for view paths, used in
View::buildandView::rebuild. These paths are used for routing messages inView::message. - View
Sequence - Views for ordered sequences of elements.
Functions§
- fork
- Create a view which acts as
active_view, whilst also runningalongside_view, without inserting it into the tree. - frozen
- This view can be used, when the view returned by
init_viewdoesn’t access theState, other than in event callbacks It only evaluates theinit_viewonce, when it’s being created. - lens
- An adapter which allows using a component which only uses one field of the current state.
- map_
action - A view that maps a child
View<State,ChildAction,_>toView<State,ParentAction,_>while providing mutable access toStatein the map function. - map_
message - A view which maps a child
View<State,ChildAction,_>toView<State,ParentAction,_>, whilst allowing the kind ofMessageResultto be changed. - map_
state - A view that “extracts” state from a
View<ParentState,_,_>toView<ChildState,_,_>. This allows modularization of views based on their state. - memoize
- Memoize the view, until the
datachanges (in which caseviewis called again) - on_
action_ with_ context - Operate on an environment value when a child view returns an action.
- provides
- View which makes a
Resourcevalue of a specific type available to all of its descendants. - run_
once - A view which executes
onceexactly once. - run_
once_ raw - A view which executes
onceexactly once. - with_
context - View which gives access to a
Resourcevalue from its environment. - without_
elements - An adapter which turns a
ViewSequencecontaining any number of views with side effects, into aViewSequencewith any element type.
Type Aliases§
- Mut
- This alias is syntax sugar to avoid the elaborate expansion of
<Self::Element as ViewElement>::Mut<'el>in the View trait when implementing it (e.g. via rust-analyzer)