Res

Trait Res 

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

Source

fn get_value(&self, _: &impl DataContext) -> T

Returns the value of a resource by value.

Provided Methods§

Source

fn set_or_bind<F>(self, cx: &mut Context, closure: F)
where Self: Sized, F: 'static + Fn(&mut Context, Self),

Source

fn to_signal(self, cx: &mut Context) -> Signal<T>
where Self: Sized + 'static, T: Clone + 'static,

Converts this signal into a signal mirror tied to entity.

Reactive signals keep the returned signal updated over time, while non-reactive values initialize it once.

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.

Implementations on Foreign Types§

Source§

impl Res<bool> for bool

Source§

fn get_value(&self, _: &impl DataContext) -> bool

Source§

impl Res<char> for char

Source§

fn get_value(&self, _: &impl DataContext) -> char

Source§

impl Res<f32> for f32

Source§

fn get_value(&self, _: &impl DataContext) -> f32

Source§

impl Res<f64> for f64

Source§

fn get_value(&self, _: &impl DataContext) -> f64

Source§

impl Res<i8> for i8

Source§

fn get_value(&self, _: &impl DataContext) -> i8

Source§

impl Res<i16> for i16

Source§

fn get_value(&self, _: &impl DataContext) -> i16

Source§

impl Res<i32> for i32

Source§

fn get_value(&self, _: &impl DataContext) -> i32

Source§

impl Res<i64> for i64

Source§

fn get_value(&self, _: &impl DataContext) -> i64

Source§

impl Res<i128> for i128

Source§

fn get_value(&self, _: &impl DataContext) -> i128

Source§

impl Res<isize> for isize

Source§

fn get_value(&self, _: &impl DataContext) -> isize

Source§

impl Res<u8> for u8

Source§

fn get_value(&self, _: &impl DataContext) -> u8

Source§

impl Res<u16> for u16

Source§

fn get_value(&self, _: &impl DataContext) -> u16

Source§

impl Res<u32> for u32

Source§

fn get_value(&self, _: &impl DataContext) -> u32

Source§

impl Res<u64> for u64

Source§

fn get_value(&self, _: &impl DataContext) -> u64

Source§

impl Res<u128> for u128

Source§

fn get_value(&self, _: &impl DataContext) -> u128

Source§

impl Res<usize> for usize

Source§

fn get_value(&self, _: &impl DataContext) -> usize

Source§

impl Res<String> for String

Source§

fn get_value(&self, _: &impl DataContext) -> String

Source§

impl Res<Range<f32>> for Range<f32>

Source§

fn get_value(&self, _: &impl DataContext) -> Range<f32>

Source§

impl<'s> Res<&'s str> for &'s str

Source§

fn get_value(&self, _: &impl DataContext) -> &'s str

Source§

impl<'s> Res<&'s String> for &'s String

Source§

fn get_value(&self, _: &impl DataContext) -> &'s String

Source§

impl<T1, T2> Res<(T1, T2)> for (T1, T2)
where T1: Clone, T2: Clone,

Source§

fn get_value(&self, _cx: &impl DataContext) -> (T1, T2)

Source§

impl<T1, T2, T3> Res<(T1, T2, T3)> for (T1, T2, T3)
where T1: Clone, T2: Clone, T3: Clone,

Source§

fn get_value(&self, _cx: &impl DataContext) -> (T1, T2, T3)

Source§

impl<T1, T2, T3, T4> Res<(T1, T2, T3, T4)> for (T1, T2, T3, T4)
where T1: Clone, T2: Clone, T3: Clone, T4: Clone,

Source§

impl<T> Res<Option<T>> for Option<T>
where T: Clone + Res<T>,

Source§

fn get_value(&self, _: &impl DataContext) -> Option<T>

Source§

impl<T> Res<Vec<T>> for &'static [T]
where T: Clone + 'static,

Source§

fn get_value(&self, _: &impl DataContext) -> Vec<T>

Source§

impl<T> Res<Vec<T>> for Vec<T>
where T: Clone + Res<T>,

Source§

fn get_value(&self, _: &impl DataContext) -> Vec<T>

Source§

impl<T, O, GF, UF> Res<O> for DerivedSignal<T, O, GF, UF>
where T: Clone + 'static, O: Clone + 'static, GF: Fn(&T) -> O + Copy + 'static, UF: Fn(&O) -> T + Copy + 'static,

Source§

fn get_value(&self, _: &impl DataContext) -> O

Source§

fn set_or_bind<F>(self, cx: &mut Context, closure: F)
where F: 'static + Fn(&mut Context, DerivedSignal<T, O, GF, UF>),

Source§

impl<T, const N: usize> Res<[T; N]> for [T; N]
where T: Clone + Res<T>,

Source§

fn get_value(&self, _: &impl DataContext) -> [T; N]

Implementors§

Source§

impl Res<Alignment> for Alignment

Source§

impl Res<Anchor> for Anchor

Source§

impl Res<AnchorTarget> for AnchorTarget

Source§

impl Res<Angle> for Angle

Source§

impl Res<AvatarVariant> for AvatarVariant

Source§

impl Res<BadgePlacement> for BadgePlacement

Source§

impl Res<ButtonVariant> for ButtonVariant

Source§

impl Res<ChipVariant> for ChipVariant

Source§

impl Res<Color> for Color

Source§

impl Res<CornerShape> for CornerShape

Source§

impl Res<CursorIcon> for CursorIcon

Source§

impl Res<Display> for Display

Source§

impl Res<FamilyOwned> for FamilyOwned

Source§

impl Res<Filter> for Filter

Source§

impl Res<FontSlant> for FontSlant

Source§

impl Res<FontWeightKeyword> for FontWeightKeyword

Source§

impl Res<FontWidth> for FontWidth

Source§

impl Res<LayoutType> for LayoutType

Source§

impl Res<Length> for Length

Source§

impl Res<LengthOrPercentage> for LengthOrPercentage

Source§

impl Res<LengthValue> for LengthValue

Source§

impl Res<Orientation> for Orientation

Source§

impl Res<Overflow> for Overflow

Source§

impl Res<Placement> for Placement

Source§

impl Res<PointerEvents> for PointerEvents

Source§

impl Res<PositionType> for PositionType

Source§

impl Res<Selectable> for Selectable

Source§

impl Res<SpinboxIcons> for SpinboxIcons

Source§

impl Res<TextAlign> for TextAlign

Source§

impl Res<TextOverflow> for TextOverflow

Source§

impl Res<TextStrokeStyle> for TextStrokeStyle

Source§

impl Res<Transform> for Transform

Source§

impl Res<Units> for Units

Source§

impl Res<Visibility> for Visibility

Source§

impl Res<FontVariation> for FontVariation

Source§

impl Res<FontWeight> for FontWeight

Source§

impl Res<LineClamp> for LineClamp

Source§

impl Res<LinearGradient> for LinearGradient

Source§

impl Res<LinearGradientBuilder> for LinearGradientBuilder

Source§

impl Res<Opacity> for Opacity

Source§

impl Res<Position> for Position

Source§

impl Res<RGBA> for RGBA

Source§

impl Res<Scale> for Scale

Source§

impl Res<Shadow> for Shadow

Source§

impl Res<ShadowBuilder> for ShadowBuilder

Source§

impl Res<TextDecorationLine> for TextDecorationLine

Source§

impl Res<TextStroke> for TextStroke

Source§

impl Res<Translate> for Translate

Source§

impl Res<WindowPosition> for WindowPosition

Source§

impl Res<String> for Localized

Source§

impl<'i> Res<BackgroundImage<'i>> for BackgroundImage<'i>

Source§

impl<'i> Res<FontFamily<'i>> for FontFamily<'i>

Source§

impl<T> Res<T> for Memo<T>
where T: Clone + PartialEq + 'static,

Source§

impl<T> Res<T> for ReadSignal<T>
where T: Clone + 'static,

Source§

impl<T> Res<T> for Signal<T>
where T: Clone + 'static,

Source§

impl<T> Res<T> for SyncReadSignal<T>
where T: Clone + Send + Sync + 'static,

Source§

impl<T> Res<T> for SyncSignal<T>
where T: Clone + Send + Sync + 'static,

Source§

impl<T, O, GF, UF> Res<O> for SyncDerivedSignal<T, O, GF, UF>
where T: Clone + Send + Sync + 'static, O: Clone + Send + Sync + 'static, GF: Fn(&T) -> O + Copy + Send + Sync + 'static, UF: Fn(&O) -> T + Copy + Send + Sync + 'static,