Skip to main content

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<FluentNaiveDateTime> for NaiveDateTime

Source§

impl Res<String> for String

Source§

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

Source§

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

Source§

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

Source§

impl Res<Anchor> for Anchor

Source§

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

Source§

impl Res<AnchorTarget> for AnchorTarget

Source§

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

Source§

impl Res<FluentNumber> for FluentNumber

Source§

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

Source§

impl Res<WindowPosition> for WindowPosition

Source§

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

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) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

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, Self),

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,

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, Self),

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T: PartialEq + 'static, S: View, K: Clone + PartialEq + Send + Sync + 'static> Res<Vec<TableColumn<T, S, K>>> for Vec<TableColumn<T, S, K>>

Source§

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

Source§

impl<Tz: TimeZone + Clone + 'static> Res<FluentDateTime<Tz>> for DateTime<Tz>

Source§

fn get_value(&self, _: &impl DataContext) -> FluentDateTime<Tz>

Implementors§

Source§

impl Res<LayoutType> for LayoutType

Source§

impl Res<PositionType> for PositionType

Source§

impl Res<Units> for Units

Source§

impl Res<ControlSize> for ControlSize

Source§

impl Res<Alignment> for Alignment

Source§

impl Res<Angle> for Angle

Source§

impl Res<Color> for Color

Source§

impl Res<CornerShape> for CornerShape

Source§

impl Res<CursorIcon> for CursorIcon

Source§

impl Res<Direction> for Direction

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<LayoutWrap> for LayoutWrap

Source§

impl Res<Length> for Length

Source§

impl Res<LengthOrPercentage> for LengthOrPercentage

Source§

impl Res<LengthValue> for LengthValue

Source§

impl Res<Overflow> for Overflow

Source§

impl Res<PointerEvents> for PointerEvents

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<Visibility> for Visibility

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<Orientation> for Orientation

Source§

impl Res<Placement> for Placement

Source§

impl Res<Selectable> for Selectable

Source§

impl Res<SpinboxIcons> for SpinboxIcons

Source§

impl Res<TableSortCycle> for TableSortCycle

Source§

impl Res<TableSortDirection> for TableSortDirection

Source§

impl Res<FluentNaiveDateTime> for FluentNaiveDateTime

Source§

impl Res<LinearGradientBuilder> for LinearGradientBuilder

Source§

impl Res<ShadowBuilder> for ShadowBuilder

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<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<TextDecorationLine> for TextDecorationLine

Source§

impl Res<TextStroke> for TextStroke

Source§

impl Res<Translate> for Translate

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<Tz: TimeZone + Clone + 'static> Res<FluentDateTime<Tz>> for FluentDateTime<Tz>