[][src]Struct druid::LensWrap

pub struct LensWrap<U, L, W> { /* fields omitted */ }

A wrapper for its widget subtree to have access to a part of its parent's data.

Every widget in druid is instantiated with access to data of some type; the root widget has access to the entire application data. Often, a part of the widget hierarchy is only concerned with a part of that data. The LensWrap widget is a way to "focus" the data reference down, for the subtree. One advantage is performance; data changes that don't intersect the scope of the lens aren't propagated.

Another advantage is generality and reuse. If a widget (or tree of widgets) is designed to work with some chunk of data, then with a lens that same code can easily be reused across all occurrences of that chunk within the application state.

This wrapper takes a Lens as an argument, which is a specification of a struct field, or some other way of narrowing the scope.

Implementations

impl<U, L, W> LensWrap<U, L, W>[src]

pub fn new(inner: W, lens: L) -> LensWrap<U, L, W>[src]

Wrap a widget with a lens.

When the lens has type Lens<T, U>, the inner widget has data of type U, and the wrapped widget has data of type T.

Trait Implementations

impl<T, U, L, W> Widget<T> for LensWrap<U, L, W> where
    T: Data,
    U: Data,
    L: Lens<T, U>,
    W: Widget<U>, 
[src]

Auto Trait Implementations

impl<U, L, W> RefUnwindSafe for LensWrap<U, L, W> where
    L: RefUnwindSafe,
    U: RefUnwindSafe,
    W: RefUnwindSafe

impl<U, L, W> Send for LensWrap<U, L, W> where
    L: Send,
    U: Send,
    W: Send

impl<U, L, W> Sync for LensWrap<U, L, W> where
    L: Sync,
    U: Sync,
    W: Sync

impl<U, L, W> Unpin for LensWrap<U, L, W> where
    L: Unpin,
    U: Unpin,
    W: Unpin

impl<U, L, W> UnwindSafe for LensWrap<U, L, W> where
    L: UnwindSafe,
    U: UnwindSafe,
    W: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.