cushy::reactive

Trait Unwrapped

Source
pub trait Unwrapped<T>: Sized {
    type Value<'a>;

    // Required methods
    fn unwrapped_or_else(self, initial: impl FnOnce() -> T) -> Dynamic<T>;
    fn for_each_unwrapped_try<ForEach>(
        self,
        for_each: ForEach,
    ) -> CallbackHandle
       where ForEach: for<'a> FnMut(Self::Value<'a>) -> Result<(), CallbackDisconnected> + Send + 'static;

    // Provided methods
    fn unwrapped(self) -> Dynamic<T>
       where T: Default { ... }
    fn for_each_unwrapped<ForEach>(self, for_each: ForEach) -> CallbackHandle
       where ForEach: for<'a> FnMut(Self::Value<'a>) + Send + 'static { ... }
}
Expand description

Unwrap values contained in a dynamic source.

Required Associated Types§

Source

type Value<'a>

The value type provided to the for each functions.

Required Methods§

Source

fn unwrapped_or_else(self, initial: impl FnOnce() -> T) -> Dynamic<T>

Returns a dynamic that is updated with the unwrapped contents of thie source.

The initial value of this dynamic will be the result of unwrap_or_else(initial) on the value currently contained in this source.

Source

fn for_each_unwrapped_try<ForEach>(self, for_each: ForEach) -> CallbackHandle
where ForEach: for<'a> FnMut(Self::Value<'a>) -> Result<(), CallbackDisconnected> + Send + 'static,

Invokes for_each when self is updated with a value that can be unwrapped.

Returning Err(CallbackDisconnected) will prevent the callback from being invoked again.

Provided Methods§

Source

fn unwrapped(self) -> Dynamic<T>
where T: Default,

Returns a dynamic that is updated with the unwrapped contents of thie source.

The initial value of this dynamic will be the result of unwrap_or_default() on the value currently contained in this source.

Source

fn for_each_unwrapped<ForEach>(self, for_each: ForEach) -> CallbackHandle
where ForEach: for<'a> FnMut(Self::Value<'a>) + Send + 'static,

Invokes for_each when self is updated with a value that can be unwrapped.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'s, T, U> Unwrapped<U> for &'s Dynamic<T>
where for<'a> &'a T: IntoOption<&'a U>, T: Send + 'static, U: Clone + Send + 'static,

Source§

type Value<'a> = &'a U

Source§

impl<'s, T, U> Unwrapped<U> for &'s DynamicReader<T>
where for<'a> &'a T: IntoOption<&'a U>, T: Send + 'static, U: Clone + Send + 'static,

Source§

type Value<'a> = &'a U

Source§

impl<'s, T, U> Unwrapped<U> for &'s Owned<T>
where for<'a> &'a T: IntoOption<&'a U>, T: Send + 'static, U: Clone + Send + 'static,

Source§

type Value<'a> = &'a U

Source§

impl<T> Unwrapped<T> for Receiver<Option<T>>
where T: Send + 'static,

Source§

type Value<'a> = T

Source§

impl<T, E> Unwrapped<T> for Receiver<Result<T, E>>
where T: Send + 'static, E: Send + 'static,

Source§

type Value<'a> = T

Source§

impl<T, U> Unwrapped<U> for &BroadcastChannel<T>
where T: IntoOption<U> + Clone + Unpin + Send + 'static, U: Send + 'static,

Source§

type Value<'a> = U