pub trait Res<T> {
// Required method
fn get_value(&self, _: &impl DataContext) -> T;
// Provided methods
fn set_or_bind<F>(self, cx: &mut Context, closure: F)
where Self: Sized,
F: 'static + Fn(&mut Context, Self) { ... }
fn to_signal(self, cx: &mut Context) -> Signal<T>
where Self: Sized + 'static,
T: Clone + 'static { ... }
}Expand description
A trait which allows passing a value or reactive source to a view or modifier.
For example, the Label view constructor takes a type which implements Res<T> where
T implements ToString. This allows the user to pass a type which implements ToString,
such as String or &str, or a signal/resource producing a type which implements ToString.
Required Methods§
Sourcefn get_value(&self, _: &impl DataContext) -> T
fn get_value(&self, _: &impl DataContext) -> T
Returns the value of a resource by value.
Provided Methods§
fn set_or_bind<F>(self, cx: &mut Context, closure: F)
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.