pub trait Binding<T>: Clone + 'staticwhere
T: 'static,{
// Required methods
fn read(&self) -> T;
fn peek(&self) -> T;
fn write(&self, v: T);
// Provided methods
fn write_preview(&self, v: T) { ... }
fn write_commit(&self, v: T) { ... }
fn write_teardown(&self, v: T) { ... }
}Expand description
A readable-writable value a control can bind to two-way: a Signal, or any projection that
knows how to read and write its own slot (day-model’s Field is the other implementor).
The trait lives here rather than in day-pieces so a store crate can implement it without depending on the piece vocabulary; day-pieces re-exports it, so piece code sees no move.
Required Methods§
Sourcefn read(&self) -> T
fn read(&self) -> T
Tracked read: the current value, subscribing the running computation to changes.
Provided Methods§
Sourcefn write_preview(&self, v: T)
fn write_preview(&self, v: T)
A live write mid-gesture (Event::ValueChanged): readers must follow, but nothing
durable should key off it. Defaults to Binding::write: a plain signal has no
notion of “durable”, and a degraded backend that never commits stays correct.
Sourcefn write_commit(&self, v: T)
fn write_commit(&self, v: T)
The settled value that ends a gesture (Event::ValueCommitted). Defaults to
Binding::write; a day-model field seals its preview session here: one change
record, one undo unit, one UPDATE for the whole drag.
Sourcefn write_teardown(&self, v: T)
fn write_teardown(&self, v: T)
Seal the last preview when its control is disposed. Persistent bindings default to committing; scope-owned signals have already received the preview and may be gone.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<F, V, U> Binding<U> for Mapped<F, V, U>
The missing case converts the stored type’s default rather than requiring the UI type to have
one: a Color has no Default, and asking every converted type for one would be a tax paid
by every caller for a case only a deleted row reaches.
impl<M> Binding<f64> for Numeric<M>
impl<S, T, V> Binding<V> for Field<S, T, V>
A field is a two-way binding: every control takes one, unchanged.