Crate infect

Source
Expand description

§infect

Crates.io Docs.rs Deps.rs Security audit Continuous integration License: MPL 2.0

A variation on the Model-View-Intent (MVI) and State-Action-Model (SAM) paradigms using

  • intents for rejecting or accepting user interaction and commands,
  • (immediate) effects for updating the model according to observed events without feedback,
  • tasks for inducing concurrent side-effects.

§Naming

The semantic distinction of external triggers, inputs, or events (as in event sourcing) into intents and effects is the characteristic difference from existing approaches. Both stimuli are combined into a messages for transporting and feeding them into the system.

Each message induces at most one task for triggering side-effects.

Combining intent, effect, and task gives infect.

§License

Licensed under the Mozilla Public License 2.0 (MPL-2.0) (see MPL-2.0.txt or https://www.mozilla.org/MPL/2.0/).

Permissions of this copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work.

§Contribution

Any contribution intentionally submitted for inclusion in the work by you shall be licensed under the Mozilla Public License 2.0 (MPL-2.0).

It is required to add the following header with the corresponding SPDX short identifier to the top of each file:

// SPDX-License-Identifier: MPL-2.0

Structs§

EffectApplied
Outcome of applying an effect to the model
MessagePort
Domain-specific wrapper around a MessageSender
TaskContext
Task execution context

Enums§

IntentHandled
Outcome of handling an intent
Message
An intent or an effect
MessageProcessed
Outcome of processing a single message
MessagesConsumed
Outcome of consuming multiple messages
ModelChanged
Model change indicator

Traits§

Model
A stateful model
ModelRender
Render the model after changed
ModelRenderHint
Control rendering after applying effects
TaskExecutor
Spawn concurrent tasks

Functions§

consume_messages
Receive and process messages until one of the stop conditions are encountered
message_channel
Create a buffered, MPSC message channel with limited capacity
process_message
Process a single message

Type Aliases§

IntentHandledResult
Isomorphic representation of IntentHandled as a Result.
MessageChannel
Buffered, MPSC message channel
MessageReceiver
Message receiver for consuming messages
MessageSender
Message sender for submitting messages