Skip to main content

Binding

Struct Binding 

Source
pub struct Binding<T>(/* private fields */)
where
    T: 'static;
Expand description

A Binding<T> represents a mutable value of type T that can be observed.

Bindings provide a reactive way to work with values. When a binding’s value changes, it can notify watchers that have registered interest in the value.

Implementations§

Source§

impl<T> Binding<T>
where T: 'static + Clone,

Source

pub fn container(value: T) -> Binding<T>

Creates a new binding from a value by wrapping it in a container.

The container provides the reactive capabilities for the value.

Source§

impl<T> Binding<T>
where T: 'static,

Source

pub fn custom( custom: impl CustomBinding<Output = T> + Clone + 'static, ) -> Binding<T>

Creates a binding that uses a custom implementation of the CustomBinding trait.

Source

pub fn get(&self) -> T

Gets the current value of the binding.

Source

pub fn get_mut(&self) -> BindingMutGuard<'_, T>

Gets mutable access to the binding’s value through a guard.

When the guard is dropped, the binding is updated with the modified value.

Note: In rust, let _ = binding.get_mut(); DO NOT immediately drop the guard. Since it just binds to a variable named _, the guard will live until the end of the current scope. Please use *guard to modify the value in one line.

§Example
use nami::Binding;
let n = Binding::i32(10);
*n.get_mut() += 5; // do not bind the guard to a let pattern...even it is `_`

Tip: For better performance when modifying container bindings, consider using the with_mut method instead.

Source

pub fn set(&self, value: T)

Sets the binding to a new value

Source

pub fn take(&self) -> T
where T: Default + Clone,

Takes the value out of the binding, replacing it with the default value.

This is equivalent to std::mem::take and notifies watchers of the change.

§Example
use nami::{binding, Binding};
let mut text: Binding<String> = binding("hello");
let taken = text.take();
assert_eq!(taken, "hello");
assert_eq!(text.get(), String::new());
Source

pub fn set_from(&self, value: impl Into<T>)

Sets the binding to a new value with automatic type conversion.

Accepts any value that implements Into<T>, providing the same ergonomic benefits as the binding() constructor.

§Examples
use nami::{binding, Binding};

let mut text: Binding<String> = binding("initial");

// Direct &str usage - no .into() or .to_string() needed
text.set_from("updated");
assert_eq!(text.get(), "updated");

let mut count: Binding<i64> = binding(0);
count.set(42);
assert_eq!(count.get(), 42i64);
Source

pub fn with_mut<R>(&self, f: impl FnOnce(&mut T) -> R) -> R
where T: Clone,

Applies a function to mutably borrow the binding’s value.

This is more efficient than get_mut() for container bindings as it avoids unnecessary cloning. The function receives a mutable reference to the value and any changes will notify watchers when the function completes.

Source

pub fn mapping<Output, Getter, Setter>( source: &Binding<T>, getter: Getter, setter: Setter, ) -> Binding<Output>
where Getter: 'static + Clone + Fn(T) -> Output, Setter: 'static + Clone + Fn(&Binding<T>, Output),

Creates a bidirectional mapping between this binding and another type.

The getter transforms values from this binding’s type to the output type. The setter transforms values from the output type back to this binding’s type.

Source

pub fn filter( &self, filter: impl Clone + Fn(&T) -> bool + 'static, ) -> Binding<T>
where T: 'static,

Creates a binding that only allows values passing a filter function.

When attempting to set a value that doesn’t pass the filter, the operation is ignored.

Source

pub fn condition( &self, condition: impl Clone + Fn(&T) -> bool + 'static, ) -> Binding<bool>
where T: 'static,

Creates a binding that maps this binding’s value to a boolean condition.

The resulting binding is read-only and reflects whether the condition is met.

§Example
let number = nami::binding(5i32);
let is_positive = number.condition(|&n: &i32| n > 0);
assert_eq!(is_positive.get(), true);
Source

pub fn equal_to(&self, other: T) -> Binding<bool>
where T: Clone + PartialEq + 'static,

Creates a binding that tracks whether this binding’s value equals a specific value.

The resulting binding is read-only.

§Example
let text = nami::binding("hello".to_string());
let is_hello = text.equal_to("hello".to_string());
assert_eq!(is_hello.get(), true);
Source§

impl<T> Binding<T>
where T: 'static,

Source

pub fn mailbox_with_executor<E>(&self, executor: E) -> BindingMailbox<T>
where E: LocalExecutor,

Attaches this Binding to a mailbox using a provided executor.

Returns a BindingMailbox which can be cloned and used to send the binding to other tasks for mutation or observation.

Source

pub fn mailbox(&self) -> BindingMailbox<T>

Attaches this Binding to a mailbox using the default native executor.

Source§

impl<T> Binding<T>
where T: PartialOrd + 'static,

Source

pub fn range(&self, range: impl RangeBounds<T> + Clone + 'static) -> Binding<T>

Creates a binding that only allows values within a specified range.

Source

pub fn clamp(&self, range: impl RangeBounds<T> + Clone + 'static) -> Binding<T>
where T: Clone,

Creates a binding that clamps values to the specified range.

Values below the range minimum are clamped to the minimum. Values above the range maximum are clamped to the maximum.

Source§

impl<T> Binding<T>
where T: Signed,

Source

pub fn sign(&self) -> Binding<bool>

Creates a binding that tracks the sign of this binding’s value.

The resulting binding is true for positive values and false for negative values. Setting true makes the value positive, setting false makes it negative.

Tip: Zero is considered positive.

§Example
use nami::Binding;
let number = Binding::i32(-10i32);
let sign = number.sign();
assert_eq!(sign.get(), false);
Source§

impl Binding<u32>

Source

pub fn u32(value: u32) -> Binding<u32>

Creates a new u32 binding with the given value.

§Example
let counter = nami::Binding::u32(42);
assert_eq!(counter.get(), 42);
Source§

impl Binding<u64>

Source

pub fn u64(value: u64) -> Binding<u64>

Creates a new u64 binding with the given value.

§Example
let counter = nami::Binding::u64(42);
assert_eq!(counter.get(), 42);
Source§

impl Binding<usize>

Source

pub fn usize(value: usize) -> Binding<usize>

Creates a new usize binding with the given value.

§Example
let index = nami::Binding::usize(10);
assert_eq!(index.get(), 10);
Source§

impl Binding<i32>

Source

pub fn i32(value: i32) -> Binding<i32>

Creates a new i32 binding with the given value.

§Example
let counter = nami::Binding::i32(42);
assert_eq!(counter.get(), 42);
Source§

impl Binding<i64>

Source

pub fn i64(value: i64) -> Binding<i64>

Creates a new i64 binding with the given value.

§Example
let counter = nami::Binding::i64(42);
assert_eq!(counter.get(), 42);
Source§

impl Binding<isize>

Source

pub fn isize(value: isize) -> Binding<isize>

Create a new isize binding with the given value.

§Example
let index = nami::Binding::isize(10);
assert_eq!(index.get(), 10);
Source§

impl Binding<f32>

Source

pub fn f32(value: f32) -> Binding<f32>

Creates a new f32 binding with the given value.

§Example
let ratio = nami::Binding::f32(3.14);
assert_eq!(ratio.get(), 3.14);
Source§

impl Binding<f64>

Source

pub fn f64(value: f64) -> Binding<f64>

Creates a new f64 binding with the given value.

§Example
let ratio = nami::Binding::f64(3.14);
assert_eq!(ratio.get(), 3.14);
Source§

impl Binding<bool>

Source

pub fn bool(value: bool) -> Binding<bool>

Creates a new bool binding with the given value.

§Example
let flag = nami::Binding::bool(true);
assert_eq!(flag.get(), true);
Source§

impl<T> Binding<T>
where T: Clone,

Source

pub fn append<Ele>(&self, ele: Ele)
where T: Extend<Ele>,

Appends an element to the binding’s value and notifies watchers.

The binding’s value must implement Extend for the element type.

§Example
let mut text: nami::Binding<String> = nami::binding(String::from("Hello"));
text.append(" World");
assert_eq!(text.get(), "Hello World");
Source§

impl<T> Binding<T>
where T: Add<Output = T> + Clone + 'static,

Source

pub fn add_assign(&self, other: T)

Applies the + operation to the binding’s current value and the provided value.

Source§

impl<T> Binding<T>
where T: Sub<Output = T> + Clone + 'static,

Source

pub fn sub_assign(&self, other: T)

Applies the - operation to the binding’s current value and the provided value.

Source§

impl<T> Binding<T>
where T: Mul<Output = T> + Clone + 'static,

Source

pub fn mul_assign(&self, other: T)

Applies the * operation to the binding’s current value and the provided value.

Source§

impl<T> Binding<T>
where T: Div<Output = T> + Clone + 'static,

Source

pub fn div_assign(&self, other: T)

Applies the / operation to the binding’s current value and the provided value.

Source§

impl<T> Binding<T>
where T: Rem<Output = T> + Clone + 'static,

Source

pub fn rem_assign(&self, other: T)

Applies the % operation to the binding’s current value and the provided value.

Source§

impl<T> Binding<T>
where T: BitAnd<Output = T> + Clone + 'static,

Source

pub fn bitand_assign(&self, other: T)

Applies the & operation to the binding’s current value and the provided value.

Source§

impl<T> Binding<T>
where T: BitOr<Output = T> + Clone + 'static,

Source

pub fn bitor_assign(&self, other: T)

Applies the | operation to the binding’s current value and the provided value.

Source§

impl<T> Binding<T>
where T: BitXor<Output = T> + Clone + 'static,

Source

pub fn bitxor_assign(&self, other: T)

Applies the ^ operation to the binding’s current value and the provided value.

Source§

impl<T> Binding<T>
where T: Shl<Output = T> + Clone + 'static,

Source

pub fn shl_assign(&self, other: T)

Applies the << operation to the binding’s current value and the provided value.

Source§

impl<T> Binding<T>
where T: Shr<Output = T> + Clone + 'static,

Source

pub fn shr_assign(&self, other: T)

Applies the >> operation to the binding’s current value and the provided value.

Source§

impl<T> Binding<Option<T>>

Source

pub fn unwrap_or_else( &self, default: impl Clone + Fn() -> T + 'static, ) -> Binding<T>
where T: Clone + 'static,

Creates a binding that unwraps the option or uses a default value from a closure.

When setting values on the returned binding, they are wrapped in Some.

§Example
let maybe_text = nami::binding(None::<String>);
let text = maybe_text.unwrap_or_else(|| "default".to_string());
assert_eq!(text.get(), "default");
Source

pub fn unwrap_or(&self, default: T) -> Binding<T>
where T: Clone + 'static,

Creates a binding that unwraps the option or uses a default value.

When setting values on the returned binding, they are wrapped in Some.

§Example
let maybe_number = nami::binding(None::<i32>);
let number = maybe_number.unwrap_or(42);
assert_eq!(number.get(), 42);
Source

pub fn unwrap_or_default(&self) -> Binding<T>
where T: Default + Clone + 'static,

Creates a binding that unwraps the option or uses the type’s default value.

When setting values on the returned binding, they are wrapped in Some.

§Example
let maybe_vec = nami::binding(None::<Vec<i32>>);
let vec: nami::Binding<Vec<i32>> = maybe_vec.unwrap_or_default();
assert!(vec.get().is_empty());
Source

pub fn some_equal_to(&self, equal: T) -> Binding<bool>
where T: Eq + Clone + 'static,

Creates a binding that tracks whether this option contains a specific value.

The resulting binding is true when this option contains Some(equal), and false when it contains Some(other_value) or None. Setting true on the result sets this binding to Some(equal). Setting false has no effect on the binding.

§Example
let maybe_text = nami::binding(Some("hello".to_string()));
let is_hello = maybe_text.some_equal_to("hello".to_string());
assert_eq!(is_hello.get(), true);
Source§

impl Binding<bool>

Source

pub fn toggle(&self)

Toggles the boolean value and notifies watchers.

True becomes false, false becomes true.

§Example
let mut flag = nami::binding(false);
flag.toggle();
assert_eq!(flag.get(), true);
Source

pub fn then<T>(&self, if_true: T) -> Binding<Option<T>>
where T: Clone + 'static,

Creates a conditional binding that returns Some(value) when true, None when false.

Setting Some(value) on the result sets this binding to true. Setting None sets this binding to false.

§Example
let is_logged_in = nami::binding(true);
let username = is_logged_in.then("alice".to_string());
assert_eq!(username.get(), Some("alice".to_string()));
Source

pub fn then_some<T>(&self, if_true: T) -> Binding<Option<T>>
where T: Clone + 'static,

Creates a conditional binding that returns Some(value) when true, None when false.

This is identical to then() but follows Rust’s Option::then_some() naming convention.

§Example
let enabled = nami::binding(false);
let button_text = enabled.then_some("Click me!".to_string());
assert_eq!(button_text.get(), None);
Source

pub fn bidirectional_select<T>(&self, if_true: T, if_false: T) -> Binding<T>
where T: Eq + Clone + 'static,

Creates a bidirectional binding that selects between two values based on this boolean.

Returns if_true when this binding is true, if_false when false. Setting the if_true value on the result sets this binding to true. Setting the if_false value sets this binding to false.

This is a two-way binding. For one-way selection (e.g., in animations), use SignalExt::select instead which doesn’t require T: Eq.

§Example
let dark_mode = nami::binding(false);
let theme = dark_mode.bidirectional_select("dark".to_string(), "light".to_string());
assert_eq!(theme.get(), "light");
Source

pub fn reverse(&self) -> Binding<bool>

Creates a binding that returns the logical inverse of this boolean binding.

When this binding is true, the returned binding is false, and vice versa. Setting a value on the returned binding will set the inverse value on this binding.

§Example
let enabled = nami::binding(true);
let disabled = enabled.reverse();
assert_eq!(disabled.get(), false);
Source§

impl<T> Binding<T>
where T: Clone + Neg<Output = T> + 'static,

Source

pub fn negate(&self) -> Binding<T>

Creates a binding that produces the negated value of this binding.

Updating the derived binding will reflect the negated value back to the source.

Source§

impl<T> Binding<T>
where T: Project,

Source

pub fn project(&self) -> <T as Project>::Projected

Projects this binding into its component parts.

This method uses the Project trait implementation to decompose the binding into separate reactive bindings for each component. Changes to any projected binding will be reflected in the original binding and vice versa.

§Examples
use nami::{Binding, binding};

let tuple_binding: Binding<(i32, i32, i32)> = binding((1, 2, 3));
let (mut a, mut b, c) = tuple_binding.project();

// Modify individual projections
a.set(10);
b.set(20);

// Original binding reflects changes
assert_eq!(tuple_binding.get(), (10, 20, 3));

Trait Implementations§

Source§

impl<T, RHS> Add<RHS> for Binding<T>
where Binding<T>: Signal<Output = T>, RHS: Signal, T: Add<<RHS as Signal>::Output> + Clone + 'static, <RHS as Signal>::Output: Clone,

Source§

type Output = Map<Zip<Binding<T>, RHS>, fn((T, <RHS as Signal>::Output)) -> <T as Add<<RHS as Signal>::Output>>::Output, <T as Add<<RHS as Signal>::Output>>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: RHS) -> <Binding<T> as Add<RHS>>::Output

Performs the + operation. Read more
Source§

impl<T, RHS> BitAnd<RHS> for Binding<T>
where Binding<T>: Signal<Output = T>, RHS: Signal, T: BitAnd<<RHS as Signal>::Output> + Clone + 'static, <RHS as Signal>::Output: Clone,

Source§

type Output = Map<Zip<Binding<T>, RHS>, fn((T, <RHS as Signal>::Output)) -> <T as BitAnd<<RHS as Signal>::Output>>::Output, <T as BitAnd<<RHS as Signal>::Output>>::Output>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: RHS) -> <Binding<T> as BitAnd<RHS>>::Output

Performs the & operation. Read more
Source§

impl<T, RHS> BitOr<RHS> for Binding<T>
where Binding<T>: Signal<Output = T>, RHS: Signal, T: BitOr<<RHS as Signal>::Output> + Clone + 'static, <RHS as Signal>::Output: Clone,

Source§

type Output = Map<Zip<Binding<T>, RHS>, fn((T, <RHS as Signal>::Output)) -> <T as BitOr<<RHS as Signal>::Output>>::Output, <T as BitOr<<RHS as Signal>::Output>>::Output>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: RHS) -> <Binding<T> as BitOr<RHS>>::Output

Performs the | operation. Read more
Source§

impl<T, RHS> BitXor<RHS> for Binding<T>
where Binding<T>: Signal<Output = T>, RHS: Signal, T: BitXor<<RHS as Signal>::Output> + Clone + 'static, <RHS as Signal>::Output: Clone,

Source§

type Output = Map<Zip<Binding<T>, RHS>, fn((T, <RHS as Signal>::Output)) -> <T as BitXor<<RHS as Signal>::Output>>::Output, <T as BitXor<<RHS as Signal>::Output>>::Output>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: RHS) -> <Binding<T> as BitXor<RHS>>::Output

Performs the ^ operation. Read more
Source§

impl<T> Clone for Binding<T>

Source§

fn clone(&self) -> Binding<T>

Creates a clone of this binding.

1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Binding<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Binding<T>
where T: Default + Clone + 'static,

Source§

fn default() -> Binding<T>

Creates a binding with the default value for type T.

Source§

impl<T, RHS> Div<RHS> for Binding<T>
where Binding<T>: Signal<Output = T>, RHS: Signal, T: Div<<RHS as Signal>::Output> + Clone + 'static, <RHS as Signal>::Output: Clone,

Source§

type Output = Map<Zip<Binding<T>, RHS>, fn((T, <RHS as Signal>::Output)) -> <T as Div<<RHS as Signal>::Output>>::Output, <T as Div<<RHS as Signal>::Output>>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: RHS) -> <Binding<T> as Div<RHS>>::Output

Performs the / operation. Read more
Source§

impl<T> From<Binding<T>> for Computed<T>

Source§

fn from(val: Binding<T>) -> Computed<T>

Converts to this type from the input type.
Source§

impl<T, RHS> Mul<RHS> for Binding<T>
where Binding<T>: Signal<Output = T>, RHS: Signal, T: Mul<<RHS as Signal>::Output> + Clone + 'static, <RHS as Signal>::Output: Clone,

Source§

type Output = Map<Zip<Binding<T>, RHS>, fn((T, <RHS as Signal>::Output)) -> <T as Mul<<RHS as Signal>::Output>>::Output, <T as Mul<<RHS as Signal>::Output>>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: RHS) -> <Binding<T> as Mul<RHS>>::Output

Performs the * operation. Read more
Source§

impl<T> Neg for Binding<T>
where T: Clone + Neg<Output = T> + 'static,

Source§

fn neg(self) -> <Binding<T> as Neg>::Output

Implements unary negation for bindings.

Source§

type Output = Binding<T>

The resulting type after applying the - operator.
Source§

impl Not for Binding<bool>

Source§

fn not(self) -> <Binding<bool> as Not>::Output

Implements the logical NOT operator for boolean bindings.

Source§

type Output = Binding<bool>

The resulting type after applying the ! operator.
Source§

impl<T, RHS> Rem<RHS> for Binding<T>
where Binding<T>: Signal<Output = T>, RHS: Signal, T: Rem<<RHS as Signal>::Output> + Clone + 'static, <RHS as Signal>::Output: Clone,

Source§

type Output = Map<Zip<Binding<T>, RHS>, fn((T, <RHS as Signal>::Output)) -> <T as Rem<<RHS as Signal>::Output>>::Output, <T as Rem<<RHS as Signal>::Output>>::Output>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: RHS) -> <Binding<T> as Rem<RHS>>::Output

Performs the % operation. Read more
Source§

impl<T, RHS> Shl<RHS> for Binding<T>
where Binding<T>: Signal<Output = T>, RHS: Signal, T: Shl<<RHS as Signal>::Output> + Clone + 'static, <RHS as Signal>::Output: Clone,

Source§

type Output = Map<Zip<Binding<T>, RHS>, fn((T, <RHS as Signal>::Output)) -> <T as Shl<<RHS as Signal>::Output>>::Output, <T as Shl<<RHS as Signal>::Output>>::Output>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: RHS) -> <Binding<T> as Shl<RHS>>::Output

Performs the << operation. Read more
Source§

impl<T, RHS> Shr<RHS> for Binding<T>
where Binding<T>: Signal<Output = T>, RHS: Signal, T: Shr<<RHS as Signal>::Output> + Clone + 'static, <RHS as Signal>::Output: Clone,

Source§

type Output = Map<Zip<Binding<T>, RHS>, fn((T, <RHS as Signal>::Output)) -> <T as Shr<<RHS as Signal>::Output>>::Output, <T as Shr<<RHS as Signal>::Output>>::Output>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: RHS) -> <Binding<T> as Shr<RHS>>::Output

Performs the >> operation. Read more
Source§

impl<T> Signal for Binding<T>
where T: 'static,

Source§

fn get(&self) -> <Binding<T> as Signal>::Output

Computes the current value of the binding.

Source§

fn watch( &self, watcher: impl Fn(Context<<Binding<T> as Signal>::Output>) + 'static, ) -> <Binding<T> as Signal>::Guard

Registers a watcher to be notified when the binding’s value changes.

Source§

type Output = T

The type of value produced by this computation.
Source§

type Guard = Box<dyn WatcherGuard>

The guard type returned by the watch method that manages watcher lifecycle.
Source§

fn identity(&self) -> Option<SignalIdentity>

Returns the stable semantic identity of this signal, when one exists. Read more
Source§

impl<T, RHS> Sub<RHS> for Binding<T>
where Binding<T>: Signal<Output = T>, RHS: Signal, T: Sub<<RHS as Signal>::Output> + Clone + 'static, <RHS as Signal>::Output: Clone,

Source§

type Output = Map<Zip<Binding<T>, RHS>, fn((T, <RHS as Signal>::Output)) -> <T as Sub<<RHS as Signal>::Output>>::Output, <T as Sub<<RHS as Signal>::Output>>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: RHS) -> <Binding<T> as Sub<RHS>>::Output

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Binding<T>

§

impl<T> !Send for Binding<T>

§

impl<T> !Sync for Binding<T>

§

impl<T> !UnwindSafe for Binding<T>

§

impl<T> Freeze for Binding<T>
where Box<dyn BindingImpl<Output = T>>: Freeze,

§

impl<T> Unpin for Binding<T>
where Box<dyn BindingImpl<Output = T>>: Unpin,

§

impl<T> UnsafeUnpin for Binding<T>
where Box<dyn BindingImpl<Output = T>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<S> AnimationExt for S
where S: SignalExt,

Source§

fn animated(&self) -> WithMetadata<Self, Animation>

Attach the system-default animation to this reactive value. Read more
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<C, F, T1, T2, Output> FlattenMap<F, (T1, T2), Output> for C
where C: Signal<Output = (T1, T2)> + 'static, F: 'static + Clone + Fn(T1, T2) -> Output, T1: 'static, T2: 'static, Output: 'static,

Source§

fn flatten_map(&self, f: F) -> Map<C, impl Clone + Fn((T1, T2)), Output>

Maps a function over the flattened elements of a nested tuple. Read more
Source§

impl<C, F, T1, T2, T3, Output> FlattenMap<F, (T1, T2, T3), Output> for C
where C: Signal<Output = ((T1, T2), T3)> + 'static, F: 'static + Clone + Fn(T1, T2, T3) -> Output, Output: 'static,

Source§

fn flatten_map(&self, f: F) -> Map<C, impl Clone + Fn(((T1, T2), T3)), Output>

Maps a function over the flattened elements of a nested tuple. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> IdentifiableExt for T

Source§

fn use_id<F, Id>(self, f: F) -> UseId<Self, F>
where F: Fn(&Self) -> Id, Id: Ord + Hash,

Wraps the value in a UseId with the provided identification function.
Source§

fn self_id(self) -> SelfId<Self>

Wraps the value in a SelfId, making the value serve as its own identifier.
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<C, Output> IntoComputed<Output> for C
where C: IntoSignal<Output> + 'static, <C as IntoSignal<Output>>::Signal: Clone + 'static,

Source§

fn into_computed(self) -> Computed<Output>

Convert this value into a Computed<Output>.

Source§

impl<C, Output> IntoSignal<Output> for C
where C: Signal, <C as Signal>::Output: 'static + Clone, Output: From<<C as Signal>::Output> + 'static,

Source§

fn into_signal(self) -> <C as IntoSignal<Output>>::Signal

Convert this computation into one that produces the desired output type.

Source§

type Signal = Map<C, fn(<C as Signal>::Output) -> Output, Output>

The specific computation type that will be produced.
Source§

impl<S> IntoSignalF32 for S
where S: Signal + 'static, <S as Signal>::Output: IntoF32,

Source§

type Signal = Map<S, fn(<S as Signal>::Output) -> f32, f32>

Concrete signal type after conversion.
Source§

fn into_signal_f32(self) -> <S as IntoSignalF32>::Signal

Converts the input into an f32 signal.
Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<C> SignalExt for C
where C: Signal,

Source§

fn map<F, Output>(&self, f: F) -> Map<Self, F, Output>
where F: 'static + Clone + Fn(Self::Output) -> Output, Output: 'static, Self: 'static,

Transforms the output of this signal using the provided function.
Source§

fn zip<B>(&self, b: &B) -> Zip<Self, B>
where B: Signal, Self::Output: Clone, <B as Signal>::Output: Clone,

Combines this signal with another signal into a tuple.
Source§

fn cached(&self) -> Cached<Self>
where Self::Output: Clone,

Wraps this signal with caching to avoid redundant computations.
Source§

fn computed(&self) -> Computed<Self::Output>
where Self: 'static,

Converts this signal into a type-erased Computed container.
Source§

fn with<T>(&self, metadata: T) -> WithMetadata<Self, T>
where T: 'static,

Attaches metadata to this signal’s watcher notifications.
Source§

fn map_into<U>(&self) -> Map<Self, fn(Self::Output) -> U, U>
where Self: 'static, Self::Output: Into<U>, U: 'static,

Transforms the output using Into::into.
Source§

fn inspect<F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, Self::Output>
where Self: 'static, Self::Output: Clone + 'static, F: 'static + Clone + Fn(&Self::Output),

Applies a side-effect function and returns the original value.
Source§

fn distinct(&self) -> Distinct<Self>
where Self::Output: PartialEq + Clone,

Creates a distinct signal that only notifies on value changes.
Source§

fn equal_to( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
where Self: 'static, Self::Output: Clone + PartialEq + 'static,

Returns true if the value equals the given value. Read more
Source§

fn condition<F>( &self, predicate: F, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
where Self: 'static, F: 'static + Clone + Fn(&Self::Output) -> bool,

Returns true if the predicate returns true for the value.
Source§

fn gt( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
where Self: 'static, Self::Output: Clone + PartialOrd + 'static,

Returns true if the value is greater than the given value.
Source§

fn lt( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
where Self: 'static, Self::Output: Clone + PartialOrd + 'static,

Returns true if the value is less than the given value.
Source§

fn ge( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
where Self: 'static, Self::Output: Clone + PartialOrd + 'static,

Returns true if the value is greater than or equal to the given value.
Source§

fn le( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
where Self: 'static, Self::Output: Clone + PartialOrd + 'static,

Returns true if the value is less than or equal to the given value.
Source§

fn is_some<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
where Self: Signal<Output = Option<T>> + 'static, T: 'static,

Returns true if the Option is Some.
Source§

fn is_none<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
where Self: Signal<Output = Option<T>> + 'static, T: 'static,

Returns true if the Option is None.
Source§

fn unwrap_or<T>( &self, default: T, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, T>
where Self: Signal<Output = Option<T>> + 'static, T: Clone + 'static,

Returns the contained value or a default.
Source§

fn unwrap_or_else<T, F>( &self, default: F, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, T>
where Self: Signal<Output = Option<T>> + 'static, T: 'static, F: 'static + Clone + Fn() -> T,

Returns the contained value or computes it from a closure.
Source§

fn unwrap_or_default<T>(&self) -> Map<Self, fn(Option<T>) -> T, T>
where Self: Signal<Output = Option<T>> + 'static, T: Default + 'static,

Returns the contained value or the default value for that type.
Source§

fn some_equal_to<T>( &self, value: T, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, bool>
where Self: Signal<Output = Option<T>> + 'static, T: Clone + PartialEq + 'static,

Returns true if the Option is Some and the value equals the given value.
Source§

fn flatten<T>(&self) -> Map<Self, fn(Option<Option<T>>) -> Option<T>, Option<T>>
where Self: Signal<Output = Option<Option<T>>> + 'static, T: 'static,

Flattens a nested Option<Option<T>> into Option<T>.
Source§

fn map_some<T, U, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, Option<U>>
where Self: Signal<Output = Option<T>> + 'static, T: 'static, U: 'static, F: 'static + Clone + Fn(T) -> U,

Maps an Option<T> to Option<U> using the provided function.
Source§

fn and_then_some<T, U, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, Option<U>>
where Self: Signal<Output = Option<T>> + 'static, T: 'static, U: 'static, F: 'static + Clone + Fn(T) -> Option<U>,

Returns None if the option is None, otherwise calls f with the wrapped value and returns the result.
Source§

fn not(&self) -> Map<Self, fn(bool) -> bool, bool>
where Self: Signal<Output = bool> + 'static,

Returns the logical negation of the boolean value.
Source§

fn and<B>(&self, other: &B) -> Map<Zip<Self, B>, fn((bool, bool)) -> bool, bool>
where Self: Signal<Output = bool> + 'static, B: Signal<Output = bool> + 'static,

Returns the logical AND of this signal with another boolean signal.
Source§

fn or<B>(&self, other: &B) -> Map<Zip<Self, B>, fn((bool, bool)) -> bool, bool>
where Self: Signal<Output = bool> + 'static, B: Signal<Output = bool> + 'static,

Returns the logical OR of this signal with another boolean signal.
Source§

fn then_some<T>( &self, value: T, ) -> Map<Self, impl Clone + Fn(bool) + 'static, Option<T>>
where Self: Signal<Output = bool> + 'static, T: Clone + 'static,

Returns Some(value) if true, otherwise None.
Source§

fn select<T>( &self, if_true: T, if_false: T, ) -> Map<Self, impl Clone + Fn(bool) + 'static, T>
where Self: Signal<Output = bool> + 'static, T: Clone + 'static,

Returns if_true if true, otherwise if_false.
Source§

fn negate<T>(&self) -> Map<Self, fn(T) -> T, T>
where Self: Signal<Output = T> + 'static, T: Signed + 'static,

Returns the negation of the value.
Source§

fn abs<T>(&self) -> Map<Self, fn(T) -> T, T>
where Self: Signal<Output = T> + 'static, T: Signed + 'static,

Returns the absolute value.
Source§

fn sign<T>(&self) -> Map<Self, fn(T) -> bool, bool>
where Self: Signal<Output = T> + 'static, T: Signed + 'static,

Returns true if the value is not negative (i.e., positive or zero).
Source§

fn is_positive<T>(&self) -> Map<Self, fn(T) -> bool, bool>
where Self: Signal<Output = T> + 'static, T: Signed + 'static,

Returns true if the value is positive.
Source§

fn is_negative<T>(&self) -> Map<Self, fn(T) -> bool, bool>
where Self: Signal<Output = T> + 'static, T: Signed + 'static,

Returns true if the value is negative.
Source§

fn is_zero<T>(&self) -> Map<Self, fn(T) -> bool, bool>
where Self: Signal<Output = T> + 'static, T: Zero + 'static,

Returns true if the value is zero.
Source§

fn is_ok<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> bool, bool>
where Self: Signal<Output = Result<T, E>> + 'static, T: 'static, E: 'static,

Returns true if the Result is Ok.
Source§

fn is_err<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> bool, bool>
where Self: Signal<Output = Result<T, E>> + 'static, T: 'static, E: 'static,

Returns true if the Result is Err.
Source§

fn ok<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> Option<T>, Option<T>>
where Self: Signal<Output = Result<T, E>> + 'static, T: 'static, E: 'static,

Converts from Result<T, E> to Option<T>.
Source§

fn err<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> Option<E>, Option<E>>
where Self: Signal<Output = Result<T, E>> + 'static, T: 'static, E: 'static,

Converts from Result<T, E> to Option<E>.
Source§

fn unwrap_or_result<T, E>( &self, default: T, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, T>
where Self: Signal<Output = Result<T, E>> + 'static, T: Clone + 'static, E: 'static,

Returns the contained Ok value or a default.
Source§

fn unwrap_or_else_result<T, E, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, T>
where Self: Signal<Output = Result<T, E>> + 'static, T: 'static, E: 'static, F: 'static + Clone + Fn(E) -> T,

Returns the contained Ok value or computes it from the error.
Source§

fn map_ok<T, E, U, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, Result<U, E>>
where Self: Signal<Output = Result<T, E>> + 'static, T: 'static, E: 'static, U: 'static, F: 'static + Clone + Fn(T) -> U,

Maps a Result<T, E> to Result<U, E> using the provided function.
Source§

fn map_err<T, E, F, U>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, Result<T, U>>
where Self: Signal<Output = Result<T, E>> + 'static, T: 'static, E: 'static, U: 'static, F: 'static + Clone + Fn(E) -> U,

Maps a Result<T, E> to Result<T, F> using the provided function.
Source§

fn debounce(&self, duration: Duration) -> Debounce<Self, DefaultExecutor>
where Self::Output: Clone,

Creates a debounced version of this signal. Read more
Source§

fn throttle(&self, duration: Duration) -> Throttle<Self, DefaultExecutor>
where Self::Output: Clone,

Creates a throttled version of this signal. Read more
Source§

fn str_is_empty<T>(&self) -> Map<Self, fn(T) -> bool, bool>
where Self: Signal<Output = T> + 'static, T: AsRef<str> + 'static,

Returns true if the string is empty. Read more
Source§

fn str_len<T>(&self) -> Map<Self, fn(T) -> usize, usize>
where Self: Signal<Output = T> + 'static, T: AsRef<str> + 'static,

Returns the length of the string in bytes.
Source§

fn str_contains<T>( &self, pattern: impl Into<String>, ) -> Map<Self, impl Clone + Fn(T) + 'static, bool>
where Self: Signal<Output = T> + 'static, T: AsRef<str> + 'static,

Returns true if the string contains the given pattern. Read more
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 = !

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.