Skip to main content

AnyBinding

Struct AnyBinding 

Source
pub struct AnyBinding<T: 'static> { /* private fields */ }
Expand description

A type-erased Binding: what a piece stores when its builder takes impl Binding<T> (docs/api-style.md “Three input spellings”), so the piece itself needs no type parameter per bound value.

Copy, like Signal, so it captures into closures the same way: the erased binding lives in a slot owned by the reactive scope that created it, which is the scope building the piece. Reads and writes forward to the binding it wraps, preview and commit included.

Implementations§

Source§

impl<T: 'static> AnyBinding<T>

Source

pub fn new(binding: impl Binding<T>) -> Self

Erase binding. Call it where the piece is built: the slot belongs to the current scope.

Source

pub fn get(self) -> T

Tracked read.

Source

pub fn try_get(self) -> Option<T>

Tracked read, or None once the scope that created the binding is disposed.

Source

pub fn get_untracked(self) -> T

Untracked read.

Source

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

Tracked read through a projection.

Source

pub fn set(self, v: T)

Write, waking whatever tracks the binding.

Source

pub fn set_if_changed(self, v: T)
where T: PartialEq,

Write only when the value differs from the current one.

Source

pub fn update(self, f: impl FnOnce(&mut T))

Read the current value, let f change it, write it back.

Trait Implementations§

Source§

impl<T: 'static> Binding<T> for AnyBinding<T>

Source§

fn read(&self) -> T

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

fn peek(&self) -> T

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

fn write(&self, v: T)

Write the value, waking whatever tracks it.
Source§

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

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.
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<T: 'static> Clone for AnyBinding<T>

Source§

fn clone(&self) -> Self

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<T: 'static> Copy for AnyBinding<T>

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for AnyBinding<T>

§

impl<T> !Send for AnyBinding<T>

§

impl<T> !Sync for AnyBinding<T>

§

impl<T> !UnwindSafe for AnyBinding<T>

§

impl<T> Freeze for AnyBinding<T>

§

impl<T> Unpin for AnyBinding<T>

§

impl<T> UnsafeUnpin for AnyBinding<T>

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
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> 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.
Day API ↩ Guides· daybrite.dev