Skip to main content

Res

Trait Res 

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§

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

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".

Implementations on Foreign Types§

§

impl Res<FluentNaiveDateTime> for NaiveDateTime

§

impl Res<FluentNumber> for FluentNumber

§

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

§

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

§

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

§

impl Res<String> for String

§

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

§

impl Res<bool> for bool

§

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

§

impl Res<char> for char

§

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

§

impl Res<f32> for f32

§

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

§

impl Res<f64> for f64

§

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

§

impl Res<i8> for i8

§

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

§

impl Res<i16> for i16

§

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

§

impl Res<i32> for i32

§

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

§

impl Res<i64> for i64

§

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

§

impl Res<i128> for i128

§

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

§

impl Res<isize> for isize

§

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

§

impl Res<u8> for u8

§

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

§

impl Res<u16> for u16

§

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

§

impl Res<u32> for u32

§

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

§

impl Res<u64> for u64

§

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

§

impl Res<u128> for u128

§

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

§

impl Res<usize> for usize

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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,

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

Implementors§

§

impl Res<Alignment> for Alignment

§

impl Res<Anchor> for Anchor

§

impl Res<AnchorTarget> for AnchorTarget

§

impl Res<Angle> for Angle

§

impl Res<AvatarVariant> for AvatarVariant

§

impl Res<BackgroundSize> for BackgroundSize

§

impl Res<BadgePlacement> for BadgePlacement

§

impl Res<BorderStyleKeyword> for BorderStyleKeyword

§

impl Res<ButtonVariant> for ButtonVariant

§

impl Res<ChipVariant> for ChipVariant

§

impl Res<Color> for Color

§

impl Res<ControlSize> for ControlSize

§

impl Res<CursorIcon> for CursorIcon

§

impl Res<Direction> for Direction

§

impl Res<Display> for Display

§

impl Res<FamilyOwned> for FamilyOwned

§

impl Res<Filter> for Filter

§

impl Res<FluentNaiveDateTime> for FluentNaiveDateTime

§

impl Res<FontSizeKeyword> for FontSizeKeyword

§

impl Res<FontSlant> for FontSlant

§

impl Res<FontVariation> for FontVariation

§

impl Res<FontWeight> for FontWeight

§

impl Res<FontWeightKeyword> for FontWeightKeyword

§

impl Res<FontWidth> for FontWidth

§

impl Res<LayoutType> for LayoutType

§

impl Res<LayoutWrap> for LayoutWrap

§

impl Res<Length> for Length

§

impl Res<LengthOrPercentage> for LengthOrPercentage

§

impl Res<LengthValue> for LengthValue

§

impl Res<LineClamp> for LineClamp

§

impl Res<LinearGradient> for LinearGradient

§

impl Res<LinearGradientBuilder> for LinearGradientBuilder

§

impl Res<Opacity> for Opacity

§

impl Res<Orientation> for Orientation

§

impl Res<Overflow> for Overflow

§

impl Res<Placement> for Placement

§

impl Res<PointerEvents> for PointerEvents

§

impl Res<Position> for Position

§

impl Res<PositionType> for PositionType

§

impl Res<RGBA> for RGBA

§

impl Res<Scale> for Scale

§

impl Res<Selectable> for Selectable

§

impl Res<Shadow> for Shadow

§

impl Res<ShadowBuilder> for ShadowBuilder

§

impl Res<SpinboxIcons> for SpinboxIcons

§

impl Res<String> for Localized

§

impl Res<TableSelectionMode> for TableSelectionMode

§

impl Res<TableSortCycle> for TableSortCycle

§

impl Res<TableSortDirection> for TableSortDirection

§

impl Res<TextAlign> for TextAlign

§

impl Res<TextDecorationLine> for TextDecorationLine

§

impl Res<TextOverflow> for TextOverflow

§

impl Res<TextStroke> for TextStroke

§

impl Res<TextStrokeStyle> for TextStrokeStyle

§

impl Res<Transform> for Transform

§

impl Res<Translate> for Translate

§

impl Res<Units> for Units

§

impl Res<Visibility> for Visibility

§

impl Res<WindowPosition> for WindowPosition

§

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

§

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

§

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,

§

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

§

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

§

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

§

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

§

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

§

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