vizia::binding

Trait Lens

pub trait Lens:
    'static
    + Copy
    + Debug
    + Hash {
    type Source;
    type Target;

    // Required method
    fn view<'a>(
        &self,
        source: &'a Self::Source,
    ) -> Option<LensValue<'a, Self::Target>>;
}
Expand description

A Lens allows the construction of a reference to a piece of some data, e.g. a field of a struct.

When deriving the Lens trait on a struct, the derive macro constructs a static type which implements the Lens trait for each field. The view() method takes a reference to the struct type as input and outputs a reference to the field. This provides a way to specify a binding to a specific field of some application data.

Required Associated Types§

type Source

type Target

Required Methods§

fn view<'a>( &self, source: &'a Self::Source, ) -> Option<LensValue<'a, Self::Target>>

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl<T> Lens for &'static T
where T: 'static + Copy + Debug + Hash,

§

type Source = ()

§

type Target = T

§

fn view<'a>( &self, _source: &'a <&'static T as Lens>::Source, ) -> Option<LensValue<'a, <&'static T as Lens>::Target>>

Implementors§

§

impl Lens for caret_timer

§

impl Lens for locale

§

type Source = Environment

§

type Target = LanguageIdentifier

§

impl Lens for vizia::environment::environment_derived_lenses::root

§

impl Lens for theme

§

impl Lens for app_theme

§

impl Lens for vizia::environment::theme_derived_lenses::root

§

impl Lens for sys_theme

§

impl Lens for menu_visible

§

impl Lens for vizia::modifiers::modal_model_derived_lenses::root

§

impl Lens for tooltip_visible

§

impl Lens for vizia::views::badge_derived_lenses::placement

§

impl Lens for vizia::views::badge_derived_lenses::root

§

impl Lens for on_close

§

type Source = Chip

§

type Target = Option<Arc<dyn Fn(&mut EventContext<'_>) + Sync + Send>>

§

impl Lens for vizia::views::chip_derived_lenses::root

§

type Source = Chip

§

type Target = Chip

§

impl Lens for list_len

§

impl Lens for vizia::views::list_derived_lenses::root

§

type Source = List

§

type Target = List

§

impl Lens for vizia::views::menu_bar_derived_lenses::is_open

§

impl Lens for vizia::views::menu_bar_derived_lenses::root

§

impl Lens for vizia::views::menu_button_derived_lenses::root

§

impl Lens for vizia::views::popup_data_derived_lenses::is_open

§

impl Lens for vizia::views::popup_data_derived_lenses::root

§

impl Lens for arrow_size

§

impl Lens for vizia::views::popup_derived_lenses::placement

§

impl Lens for vizia::views::popup_derived_lenses::root

§

impl Lens for should_reposition

§

impl Lens for show_arrow

§

impl Lens for vizia::views::submenu_derived_lenses::is_open

§

impl Lens for is_submenu

§

impl Lens for open_on_hover

§

impl Lens for vizia::views::submenu_derived_lenses::root

§

impl Lens for on_change

§

impl Lens for vizia::views::virtual_list_derived_lenses::root

§

impl Lens for scroll_to_cursor

§

impl<A, B> Lens for Then<A, B>
where A: Lens, B: Lens<Source = <A as Lens>::Target>,

§

type Source = <A as Lens>::Source

§

type Target = <B as Lens>::Target

§

impl<L1, L2> Lens for AndLens<L1, L2>
where L2: Lens<Target = bool>, L1: Lens<Source = <L2 as Lens>::Source, Target = bool>,

§

type Source = <L1 as Lens>::Source

§

type Target = bool

§

impl<L1, L2> Lens for OrLens<L1, L2>
where L2: Lens<Target = bool>, L1: Lens<Source = <L2 as Lens>::Source, Target = bool>,

§

type Source = <L1 as Lens>::Source

§

type Target = bool

§

impl<L1, L2> Lens for RatioLens<L1, L2>
where L1: Clone + Lens<Target = f32> + 'static, L2: 'static + Clone + Lens<Target = f32, Source = <L1 as Lens>::Source>,

§

type Source = <L1 as Lens>::Source

§

type Target = f32

§

impl<L1, L2, T> Lens for filter_text<L1, L2, T>
where L1: Lens<Target = Vec<T>>, L2: Lens<Target = usize>, T: 'static + Data + ToString,

§

type Source = ComboBox<L1, L2, T>

§

type Target = String

§

impl<L1, L2, T> Lens for hovered<L1, L2, T>
where L1: Lens<Target = Vec<T>>, L2: Lens<Target = usize>, T: 'static + Data + ToString,

§

type Source = ComboBox<L1, L2, T>

§

type Target = usize

§

impl<L1, L2, T> Lens for vizia::views::combo_box_derived_lenses::is_open<L1, L2, T>
where L1: Lens<Target = Vec<T>>, L2: Lens<Target = usize>, T: 'static + Data + ToString,

§

type Source = ComboBox<L1, L2, T>

§

type Target = bool

§

impl<L1, L2, T> Lens for list_lens<L1, L2, T>
where L1: Lens<Target = Vec<T>>, L2: Lens<Target = usize>, T: 'static + Data + ToString,

§

type Source = ComboBox<L1, L2, T>

§

type Target = L1

§

impl<L1, L2, T> Lens for on_select<L1, L2, T>
where L1: Lens<Target = Vec<T>>, L2: Lens<Target = usize>, T: 'static + Data + ToString,

§

type Source = ComboBox<L1, L2, T>

§

type Target = Option<Box<dyn Fn(&mut EventContext<'_>, usize)>>

§

impl<L1, L2, T> Lens for p<L1, L2, T>
where L1: Lens<Target = Vec<T>>, L2: Lens<Target = usize>, T: 'static + Data + ToString,

§

type Source = ComboBox<L1, L2, T>

§

type Target = PhantomData<T>

§

impl<L1, L2, T> Lens for placeholder<L1, L2, T>
where L1: Lens<Target = Vec<T>>, L2: Lens<Target = usize>, T: 'static + Data + ToString,

§

type Source = ComboBox<L1, L2, T>

§

type Target = String

§

impl<L1, L2, T> Lens for vizia::views::combo_box_derived_lenses::root<L1, L2, T>
where L1: Lens<Target = Vec<T>>, L2: Lens<Target = usize>, T: 'static + Data + ToString,

§

type Source = ComboBox<L1, L2, T>

§

type Target = ComboBox<L1, L2, T>

§

impl<L1, L2, T> Lens for selected<L1, L2, T>
where L1: Lens<Target = Vec<T>>, L2: Lens<Target = usize>, T: 'static + Data + ToString,

§

type Source = ComboBox<L1, L2, T>

§

type Target = L2

§

impl<L> Lens for Wrapper<L>
where L: Lens,

§

type Source = <L as Lens>::Source

§

type Target = <L as Lens>::Target

§

impl<L, O> Lens for Map<L, O>
where L: Lens, O: 'static,

§

type Source = <L as Lens>::Source

§

type Target = O

§

impl<L, O> Lens for MapRef<L, O>
where L: Lens, O: 'static + Clone,

§

type Source = <L as Lens>::Source

§

type Target = O

§

impl<L, T> Lens for Index<L, T>
where L: Lens, <L as Lens>::Target: Deref<Target = [T]>, T: 'static + Clone,

§

type Source = <L as Lens>::Source

§

type Target = T

§

impl<T> Lens for StaticLens<T>

§

type Source = ()

§

type Target = T

§

impl<T> Lens for UnwrapLens<T>
where T: 'static,

§

type Source = Option<T>

§

type Target = T

§

impl<T, U> Lens for IntoLens<T, U>
where T: 'static + Clone + TryInto<U>, U: 'static,

§

type Source = T

§

type Target = U