Skip to main content

Crate yse_model

Crate yse_model 

Source
Expand description

yse-model is the pure-Rust reactive runtime at the core of Yse.

The design is inspired by Airstream:

  • EventStream has no current value; it carries discrete events.
  • Signal always has a current value; it carries state.
  • Propagation is transactional and glitch-free: inside one transaction, derived values are recomputed in topological order, so a diamond-shaped graph never observes inconsistent intermediate state.
  • Every observation is owned by a Subscription; dropping it (directly or through an Owner) unsubscribes.

The crate is pure Rust: no Qt and no unsafe. The reactive graph itself is single-threaded; background work must return to it through a Scheduler (see spawn_task).

Structs§

CancellationToken
Cooperative cancellation token shared with a running Task.
Diagnostics
Installed diagnostics for the current thread.
EventStream
A stream of discrete events. It has no current value.
Interval
Handle to a repeating background sampler started by spawn_interval. Each sample is delivered to the thread that spawned it through the given Scheduler; subscribe with Interval::results.
ListModel
An incremental list model.
LogRecord
A structured log record.
Logger
A leveled logger whose records are observable as a stream.
ManualTimer
A test Timer that queues tasks until the test fires them.
Observer
A reusable callback handle that can observe several observables at once.
Owner
Owns a set of subscriptions and unsubscribes all of them when dropped.
QueueScheduler
A scheduler that queues tasks and runs them on demand on the calling thread. Useful for deterministic tests and for wiring background results into the reactive graph.
Signal
A read-only signal with a current value.
Sink
A writable source of stream events.
Subscription
Handle to an active observation. Dropping it unsubscribes.
SyncScheduler
A scheduler that runs tasks immediately on the current thread.
Task
Handle to a background task. The result is delivered to the thread that spawned the task through the given Scheduler; subscribe with Task::results.
UndoStack
A stack of reversible commands with reactive can_undo/can_redo state and a change stream.
Var
A writable source of signal state.

Enums§

DiagnosticEvent
A transactional graph event.
ListChange
A structural change to a ListModel.
LogLevel
Severity of a log record.

Traits§

Command
A reversible operation managed by an UndoStack.
Scheduler
Executes deferred work. Yse’s reactive graph is synchronous and single-threaded; this trait is the boundary where background work returns to the UI thread. A scheduler must run scheduled tasks on the thread that owns the reactive graph (the UI thread in a Qt application).
Timer
A source of one-shot delayed tasks. Tasks must run on the thread that owns the reactive graph.

Functions§

log
Log through the thread’s installed logger; no-op when none is installed.
log_debug
Emit a debug record through the thread’s installed logger.
log_error
Emit an error record through the thread’s installed logger.
log_info
Emit an informational record through the thread’s installed logger.
log_warn
Emit a warning record through the thread’s installed logger.
spawn_interval
Run f on a background thread every interval, delivering each sample onto the thread that owns the reactive graph via scheduler.
spawn_task
Run f on a background thread and deliver its result onto the thread that owns the reactive graph via scheduler.
transaction
Run f inside a single transaction. Nested calls join the outer transaction.