Crate xilem_core

Crate xilem_core 

Source
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§

one_of
Statically typed alternatives to the type-erased AnyView.

Structs§

AppendVec
An append only Vec.
DynMessage
A simple dynamically typed message for the View trait.
Environment
A store of values which are accessible throughout the view tree.
EnvironmentItem
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_message and map_action. Most users will want to use map_action (the latter).
MapState
The View for map_state.
Memoize
A view which supports Memoization.
MessageContext
The MessageContext is used in View::message.
MessageProxy
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.
OnActionWithContext
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.
SendMessage
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.
WithContext
The View type for with_context. See its documentation for details.
WithoutElements
The ViewSequence for without_elements, see its documentation for more context.

Enums§

Count
Classes that a ViewSequence can be a member of, grouped based on the number of elements it is known to contain.
MessageResult
The possible outcomes from a View::message
ProxyError
The potential error conditions from a RawProxy sending a message

Traits§

AnyElement
An element which can be used for an AnyView containing Child.
AnyView
A view which can have any view type where the View::Element is compatible with Element.
AsyncCtx
A Context for a View implementation which supports asynchronous message reporting.
ElementSplice
A temporary “splice” to add, update and delete in an (ordered) sequence of elements. It is mainly intended for view sequences.
OrphanView
This trait provides a way to add View implementations for types that would be restricted otherwise by the orphan rules.
PhantomView
A View which 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.
SuperElement
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.
ViewElement
A type which can be used as the Element associated type for a View.
ViewMarker
A type which can be a View. Imposes no requirements on the underlying type. Should be implemented alongside every View implementation:
ViewPathTracker
A tracker for view paths, used in View::build and View::rebuild. These paths are used for routing messages in View::message.
ViewSequence
Views for ordered sequences of elements.

Functions§

fork
Create a view which acts as active_view, whilst also running alongside_view, without inserting it into the tree.
frozen
This view can be used, when the view returned by init_view doesn’t access the State, other than in event callbacks It only evaluates the init_view once, 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,_> to View<State,ParentAction,_> while providing mutable access to State in the map function.
map_message
A view which maps a child View<State,ChildAction,_> to View<State,ParentAction,_>, whilst allowing the kind of MessageResult to be changed.
map_state
A view that “extracts” state from a View<ParentState,_,_> to View<ChildState,_,_>. This allows modularization of views based on their state.
memoize
Memoize the view, until the data changes (in which case view is called again)
on_action_with_context
Operate on an environment value when a child view returns an action.
provides
View which makes a Resource value of a specific type available to all of its descendants.
run_once
A view which executes once exactly once.
run_once_raw
A view which executes once exactly once.
with_context
View which gives access to a Resource value from its environment.
without_elements
An adapter which turns a ViewSequence containing any number of views with side effects, into a ViewSequence with 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)