pub trait SignalExt: Signal {
Show 47 methods
// Provided methods
fn map<F, Output>(&self, f: F) -> Map<Self, F, Output>
where F: 'static + Clone + Fn(Self::Output) -> Output,
Output: 'static,
Self: 'static { ... }
fn zip<B>(&self, b: &B) -> Zip<Self, B>
where B: Signal,
Self::Output: Clone,
<B as Signal>::Output: Clone { ... }
fn cached(&self) -> Cached<Self>
where Self::Output: Clone { ... }
fn computed(&self) -> Computed<Self::Output>
where Self: 'static { ... }
fn with<T>(&self, metadata: T) -> WithMetadata<Self, T>
where T: 'static { ... }
fn map_into<U>(&self) -> Map<Self, fn(Self::Output) -> U, U>
where Self: 'static,
Self::Output: Into<U>,
U: 'static { ... }
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) { ... }
fn distinct(&self) -> Distinct<Self>
where Self::Output: PartialEq + Clone { ... }
fn equal_to(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
where Self: 'static,
Self::Output: Clone + PartialEq + 'static { ... }
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 { ... }
fn gt(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
where Self: 'static,
Self::Output: Clone + PartialOrd + 'static { ... }
fn lt(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
where Self: 'static,
Self::Output: Clone + PartialOrd + 'static { ... }
fn ge(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
where Self: 'static,
Self::Output: Clone + PartialOrd + 'static { ... }
fn le(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
where Self: 'static,
Self::Output: Clone + PartialOrd + 'static { ... }
fn is_some<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
where Self: Signal<Output = Option<T>> + 'static,
T: 'static { ... }
fn is_none<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
where Self: Signal<Output = Option<T>> + 'static,
T: 'static { ... }
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 { ... }
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 { ... }
fn unwrap_or_default<T>(&self) -> Map<Self, fn(Option<T>) -> T, T>
where Self: Signal<Output = Option<T>> + 'static,
T: Default + 'static { ... }
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 { ... }
fn flatten<T>(
&self,
) -> Map<Self, fn(Option<Option<T>>) -> Option<T>, Option<T>>
where Self: Signal<Output = Option<Option<T>>> + 'static,
T: 'static { ... }
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 { ... }
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> { ... }
fn not(&self) -> Map<Self, fn(bool) -> bool, bool>
where Self: Signal<Output = bool> + 'static { ... }
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 { ... }
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 { ... }
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 { ... }
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 { ... }
fn negate<T>(&self) -> Map<Self, fn(T) -> T, T>
where Self: Signal<Output = T> + 'static,
T: Signed + 'static { ... }
fn abs<T>(&self) -> Map<Self, fn(T) -> T, T>
where Self: Signal<Output = T> + 'static,
T: Signed + 'static { ... }
fn sign<T>(&self) -> Map<Self, fn(T) -> bool, bool>
where Self: Signal<Output = T> + 'static,
T: Signed + 'static { ... }
fn is_positive<T>(&self) -> Map<Self, fn(T) -> bool, bool>
where Self: Signal<Output = T> + 'static,
T: Signed + 'static { ... }
fn is_negative<T>(&self) -> Map<Self, fn(T) -> bool, bool>
where Self: Signal<Output = T> + 'static,
T: Signed + 'static { ... }
fn is_zero<T>(&self) -> Map<Self, fn(T) -> bool, bool>
where Self: Signal<Output = T> + 'static,
T: Zero + 'static { ... }
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 { ... }
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 { ... }
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 { ... }
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 { ... }
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 { ... }
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 { ... }
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 { ... }
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 { ... }
fn debounce(&self, duration: Duration) -> Debounce<Self, DefaultExecutor>
where Self::Output: Clone { ... }
fn throttle(&self, duration: Duration) -> Throttle<Self, DefaultExecutor>
where Self::Output: Clone { ... }
fn str_is_empty<T>(&self) -> Map<Self, fn(T) -> bool, bool>
where Self: Signal<Output = T> + 'static,
T: AsRef<str> + 'static { ... }
fn str_len<T>(&self) -> Map<Self, fn(T) -> usize, usize>
where Self: Signal<Output = T> + 'static,
T: AsRef<str> + 'static { ... }
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 { ... }
}Expand description
Extension trait providing convenient methods for all Signal types.
This trait adds utility methods to any type implementing Signal,
allowing for easy chaining of operations like mapping, zipping, and caching.
All methods take &self and clone internally, as cloning is assumed cheap for reactive objects.
Provided Methods§
Sourcefn map<F, Output>(&self, f: F) -> Map<Self, F, Output>
fn map<F, Output>(&self, f: F) -> Map<Self, F, Output>
Transforms the output of this signal using the provided function.
Sourcefn cached(&self) -> Cached<Self>
fn cached(&self) -> Cached<Self>
Wraps this signal with caching to avoid redundant computations.
Sourcefn computed(&self) -> Computed<Self::Output>where
Self: 'static,
fn computed(&self) -> Computed<Self::Output>where
Self: 'static,
Converts this signal into a type-erased Computed container.
Sourcefn with<T>(&self, metadata: T) -> WithMetadata<Self, T>where
T: 'static,
fn with<T>(&self, metadata: T) -> WithMetadata<Self, T>where
T: 'static,
Attaches metadata to this signal’s watcher notifications.
Sourcefn map_into<U>(&self) -> Map<Self, fn(Self::Output) -> U, U>
fn map_into<U>(&self) -> Map<Self, fn(Self::Output) -> U, U>
Transforms the output using Into::into.
Sourcefn inspect<F>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, Self::Output>
fn inspect<F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, Self::Output>
Applies a side-effect function and returns the original value.
Sourcefn distinct(&self) -> Distinct<Self>
fn distinct(&self) -> Distinct<Self>
Creates a distinct signal that only notifies on value changes.
Sourcefn equal_to(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn equal_to( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
Returns true if the value equals the given value.
For inequality checks, use signal.equal_to(value).not().
Sourcefn condition<F>(
&self,
predicate: F,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn condition<F>( &self, predicate: F, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
Returns true if the predicate returns true for the value.
Sourcefn gt(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn gt( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
Returns true if the value is greater than the given value.
Sourcefn lt(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn lt( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
Returns true if the value is less than the given value.
Sourcefn ge(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn ge( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
Returns true if the value is greater than or equal to the given value.
Sourcefn le(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn le( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
Returns true if the value is less than or equal to the given value.
Sourcefn is_some<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
fn is_some<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
Returns true if the Option is Some.
Sourcefn is_none<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
fn is_none<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
Returns true if the Option is None.
Sourcefn unwrap_or<T>(
&self,
default: T,
) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, T>
fn unwrap_or<T>( &self, default: T, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, T>
Returns the contained value or a default.
Sourcefn unwrap_or_else<T, F>(
&self,
default: F,
) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, T>
fn unwrap_or_else<T, F>( &self, default: F, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, T>
Returns the contained value or computes it from a closure.
Sourcefn unwrap_or_default<T>(&self) -> Map<Self, fn(Option<T>) -> T, T>
fn unwrap_or_default<T>(&self) -> Map<Self, fn(Option<T>) -> T, T>
Returns the contained value or the default value for that type.
Sourcefn some_equal_to<T>(
&self,
value: T,
) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, bool>
fn some_equal_to<T>( &self, value: T, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, bool>
Returns true if the Option is Some and the value equals the given value.
Sourcefn flatten<T>(&self) -> Map<Self, fn(Option<Option<T>>) -> Option<T>, Option<T>>
fn flatten<T>(&self) -> Map<Self, fn(Option<Option<T>>) -> Option<T>, Option<T>>
Flattens a nested Option<Option<T>> into Option<T>.
Sourcefn map_some<T, U, F>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, Option<U>>
fn map_some<T, U, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, Option<U>>
Maps an Option<T> to Option<U> using the provided function.
Sourcefn and_then_some<T, U, F>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, Option<U>>
fn and_then_some<T, U, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, Option<U>>
Returns None if the option is None, otherwise calls f with the wrapped value and returns the result.
Sourcefn not(&self) -> Map<Self, fn(bool) -> bool, bool>
fn not(&self) -> Map<Self, fn(bool) -> bool, bool>
Returns the logical negation of the boolean value.
Sourcefn and<B>(&self, other: &B) -> Map<Zip<Self, B>, fn((bool, bool)) -> bool, bool>
fn and<B>(&self, other: &B) -> Map<Zip<Self, B>, fn((bool, bool)) -> bool, bool>
Returns the logical AND of this signal with another boolean signal.
Sourcefn or<B>(&self, other: &B) -> Map<Zip<Self, B>, fn((bool, bool)) -> bool, bool>
fn or<B>(&self, other: &B) -> Map<Zip<Self, B>, fn((bool, bool)) -> bool, bool>
Returns the logical OR of this signal with another boolean signal.
Sourcefn then_some<T>(
&self,
value: T,
) -> Map<Self, impl Clone + Fn(bool) + 'static, Option<T>>
fn then_some<T>( &self, value: T, ) -> Map<Self, impl Clone + Fn(bool) + 'static, Option<T>>
Returns Some(value) if true, otherwise None.
Sourcefn select<T>(
&self,
if_true: T,
if_false: T,
) -> Map<Self, impl Clone + Fn(bool) + 'static, T>
fn select<T>( &self, if_true: T, if_false: T, ) -> Map<Self, impl Clone + Fn(bool) + 'static, T>
Returns if_true if true, otherwise if_false.
Sourcefn sign<T>(&self) -> Map<Self, fn(T) -> bool, bool>
fn sign<T>(&self) -> Map<Self, fn(T) -> bool, bool>
Returns true if the value is not negative (i.e., positive or zero).
Sourcefn is_positive<T>(&self) -> Map<Self, fn(T) -> bool, bool>
fn is_positive<T>(&self) -> Map<Self, fn(T) -> bool, bool>
Returns true if the value is positive.
Sourcefn is_negative<T>(&self) -> Map<Self, fn(T) -> bool, bool>
fn is_negative<T>(&self) -> Map<Self, fn(T) -> bool, bool>
Returns true if the value is negative.
Sourcefn is_ok<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> bool, bool>
fn is_ok<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> bool, bool>
Returns true if the Result is Ok.
Sourcefn is_err<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> bool, bool>
fn is_err<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> bool, bool>
Returns true if the Result is Err.
Sourcefn ok<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> Option<T>, Option<T>>
fn ok<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> Option<T>, Option<T>>
Converts from Result<T, E> to Option<T>.
Sourcefn err<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> Option<E>, Option<E>>
fn err<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> Option<E>, Option<E>>
Converts from Result<T, E> to Option<E>.
Sourcefn unwrap_or_result<T, E>(
&self,
default: T,
) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, T>
fn unwrap_or_result<T, E>( &self, default: T, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, T>
Returns the contained Ok value or a default.
Sourcefn unwrap_or_else_result<T, E, F>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, T>
fn unwrap_or_else_result<T, E, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, T>
Returns the contained Ok value or computes it from the error.
Sourcefn map_ok<T, E, U, F>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, Result<U, E>>
fn map_ok<T, E, U, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, Result<U, E>>
Maps a Result<T, E> to Result<U, E> using the provided function.
Sourcefn map_err<T, E, F, U>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, Result<T, U>>
fn map_err<T, E, F, U>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, Result<T, U>>
Maps a Result<T, E> to Result<T, F> using the provided function.
Sourcefn debounce(&self, duration: Duration) -> Debounce<Self, DefaultExecutor>
fn debounce(&self, duration: Duration) -> Debounce<Self, DefaultExecutor>
Creates a debounced version of this signal.
The debounced signal will only emit values after the specified duration has passed without receiving new values.
Sourcefn throttle(&self, duration: Duration) -> Throttle<Self, DefaultExecutor>
fn throttle(&self, duration: Duration) -> Throttle<Self, DefaultExecutor>
Creates a throttled version of this signal.
The throttled signal will emit values at most once every specified duration, ignoring any additional values received during that period.
Sourcefn str_is_empty<T>(&self) -> Map<Self, fn(T) -> bool, bool>
fn str_is_empty<T>(&self) -> Map<Self, fn(T) -> bool, bool>
Returns true if the string is empty.
Named str_, like SignalExt::str_len and
SignalExt::str_contains, because every type that can be a constant
signal gains these methods — including Vec<T>, whose own is_empty
would otherwise be shadowed by this one at the call site.
Sourcefn str_len<T>(&self) -> Map<Self, fn(T) -> usize, usize>
fn str_len<T>(&self) -> Map<Self, fn(T) -> usize, usize>
Returns the length of the string in bytes.
Sourcefn str_contains<T>(
&self,
pattern: impl Into<String>,
) -> Map<Self, impl Clone + Fn(T) + 'static, bool>
fn str_contains<T>( &self, pattern: impl Into<String>, ) -> Map<Self, impl Clone + Fn(T) + 'static, bool>
Returns true if the string contains the given pattern.
Named str_ for the reason given on SignalExt::str_is_empty: a bare
contains here shadows <[T]>::contains on any Vec<T> in scope.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".