Crate stateful
SourceStructs§
Traits§
- Finalize
- Attempts to perform an operation after which the object will not be used anymore. Taking the object by value guarantees it won’t be used anymore.
- Inherit
- Trait useful for Java-style inheritance. It allows T to implement
all of parent’s methods if the parent’s methods live in a trait with
a default implementation for T : Inherit
. Note this trait only allows for single-parent relationships (tree-like inheritance diagram). For multiple inheritance (DAG-like inheritance diagram) Parent should be a trait type argument. A way to simulate multiple inheritance is to use Type Parent = (A, B), then to use the fields/methods of A use parent().0 and to use the fields/methods of B use parent().1 * - Initialize
- Attempts to initialize an object.
- Message
- Persistent
State - This is a minimal design pattern crate exposing the following:
- React
- Generic trait to represent interactions between Views (widgets or sets of grouped widgets affected by data change),
Models (data structures that encapsulate data-modifying algorithms) and controls (widgets
that modify the data contained in models). Widgets that affect a model (Controls) are represented by having the model imlement React
. Widgets that are affected by a model (Views) are represented by having the widget implement React . The implementation will usually bind one or more closures to the argument. Usually, an widget is either a control OR a view with respect to a given model, but might a assume both roles. A widget might also be a view for one model but the control for another model. Models usually encapsulate a call to glib::Receiver::attach(.), waiting for messages that change their state. The models are implemented by closures activated on “signals”, implemented using Rust enums. The actual data is not held in the model structure, but is owned by a single closure executing on the main thread whenever some signal enum is received. If required, the model might spawn new threads or wait for response from worker threads, but they should never block. - Stateful
- Stateful objects for any reason can live at an invalid state. This trait simply declares which conditions an object might not be valid, associating an Error type to your algorithm.
- Transition
- Trait implemented by structs whose state can be characterized as having one of a few discrete states at any given time. stateful structs or enumerations (usually enumerations) that can be at one of a few states known at compile time. Some of the transitions from state T->U might be invalid and must be specified at the implementation of self.transition. TODO rename to transition?
- Verify
- TODO move to verifiable crate, and make stateful dependent on it.
Trait implemented by stateful structs or enumerations for which
certain invariants must be held and can be verified at runtime.
You can #[derive(Verify)] if all fields of your structure satisfy
verify, in which case the error will be Box
wrapping the first violation found.
Type Aliases§
- Bind
Result - Callbacks
- Holds a set of callbacks with a given signature. Useful if several objects must respond to the same signal. If more than one object must be taken as argument, use a custom struct or tuples.