Skip to main content

Field

Struct Field 

Source
pub struct Field<S, T, V>
where T: 'static, V: 'static,
{ /* private fields */ }
Expand description

One field, projected out of any Source. Copy, itself a Source (so fields nest), and a Binding (so every control binds to it).

Implementations§

Source§

impl<S, T, V> Field<S, T, V>
where S: Source<T>, T: 'static, V: 'static,

Source

pub fn with<R>(self, f: impl FnOnce(Option<&V>) -> R) -> R

Tracked read of this field only.

Source

pub fn with_untracked<R>(self, f: impl FnOnce(Option<&V>) -> R) -> R

Source

pub fn update(self, f: impl FnOnce(&mut V))
where V: Clone,

Write, waking readers of this field and of anything coarser. When a change-log consumer asked for values (record_values), the slot’s prior and new value ride along.

Source

pub fn touch(self, tx: &mut Vec<(Vec<u64>, &'static str)>)

Name this field inside a background transaction. Portable: what is queued is the path’s components, which the main thread re-establishes on its own side when it announces.

Source

pub fn path(self) -> Path

Source

pub fn label(self) -> &'static str

Source§

impl<S, T, V> Field<S, T, V>
where S: Source<T>, T: 'static, V: 'static,

Source

pub fn map<U>( self, to: fn(&V) -> U, from: fn(&U) -> V, ) -> Mapped<Field<S, T, V>, V, U>
where U: 'static,

Read this field through to, write it back through from. Both are fn pointers, so the result stays Copy.

Source§

impl<S, T, V> Field<S, T, V>
where S: Source<T>, T: 'static, V: Clone + Default + 'static,

Source

pub fn write_preview(self, v: V)

A live write: the value lands and this field’s readers wake (a label tracking a dragged slider follows), but no change record is born, so autosave, the undo stack and every sink stay quiet. The first preview since the last commit captures the pre-session value; Field::write_commit turns the whole gesture into one record.

Source

pub fn write_commit(self, v: V)

The settled value that ends a preview sequence: applies v, then announces one change whose prior is the pre-session value, so sixty thumb positions become one record, one undo unit, one UPDATE. Without an open session this is a plain Binding::write.

Source

pub fn session(self) -> FieldSession<S, T, V>

The explicit session handle, for custom pieces and programmatic gestures; bindings drive Field::write_preview/Field::write_commit on their own.

Trait Implementations§

Source§

impl<S, T, V> Binding<V> for Field<S, T, V>
where S: Source<T>, T: 'static, V: Clone + Default + 'static,

A field is a two-way binding: every control takes one, unchanged.

Source§

fn read(&self) -> V

Tracked read: the current value, subscribing the running computation to changes.
Source§

fn peek(&self) -> V

Untracked read: the current value, subscribing nothing (the reactive world’s “peek”).
Source§

fn write(&self, v: V)

Write the value, waking whatever tracks it.
Source§

fn write_preview(&self, v: V)

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

fn write_commit(&self, v: V)

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

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

impl<S, T, V> Clone for Field<S, T, V>
where S: Copy,

Source§

fn clone(&self) -> Field<S, T, V>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S, T, V> Copy for Field<S, T, V>
where S: Copy,

Source§

impl<S, T, V> Source<V> for Field<S, T, V>
where S: Source<T>, T: 'static, V: 'static,

A field is itself a source, so item.address().city() works.

Source§

fn node(self) -> NodeId

Interning happens here and only here: when a field is used as a parent, which is what nesting one struct inside another means.

Source§

const DYNAMIC: bool = S::DYNAMIC

Whether this source’s location can change over the handle’s lifetime: a recycled list slot whose current row rotates. Fields projected from a dynamic source resolve their path through the source on every operation instead of trusting the one cached at projection time, and their tracked reads also run Source::track_extra.
Source§

fn track_extra(self)

Extra tracking a projected field’s tracked reads perform. A dynamic source tracks its own rebind signal here, so a control bound at build follows the slot to its next row.
Source§

fn path(self) -> Path

The path this source occupies. Implementations revalidate against the interner, so the result is always current.
Source§

fn components(self, out: &mut Vec<u64>)

The path as plain components, resolved by walking the handle chain rather than the interner. This is what crosses a thread boundary: a worker names what it changed with components, and the main thread re-establishes them on its own side when it announces.
Source§

fn with_value_untracked<R>(self, f: impl FnOnce(Option<&V>) -> R) -> R

Source§

fn update_value(self, f: impl FnOnce(&mut V)) -> bool

Returns false when the value is gone (a deleted row), in which case nothing is announced either.
Source§

fn bump_version(self)

Source§

fn with<R>(self, f: impl FnOnce(Option<&T>) -> R) -> R

Tracked read of the whole value: the coarse subscription.

Auto Trait Implementations§

§

impl<S, T, V> Freeze for Field<S, T, V>
where S: Freeze,

§

impl<S, T, V> RefUnwindSafe for Field<S, T, V>
where S: RefUnwindSafe,

§

impl<S, T, V> Send for Field<S, T, V>
where S: Send,

§

impl<S, T, V> Sync for Field<S, T, V>
where S: Sync,

§

impl<S, T, V> Unpin for Field<S, T, V>
where S: Unpin,

§

impl<S, T, V> UnsafeUnpin for Field<S, T, V>
where S: UnsafeUnpin,

§

impl<S, T, V> UnwindSafe for Field<S, T, V>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoReactive<T, StaticMark> for T
where T: Clone + 'static,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.