[][src]Struct druid::Env

pub struct Env(_);

An environment passed down through all widget traversals.

All widget methods have access to an environment, and it is passed downwards during traversals.

A widget can retrieve theme parameters (colors, dimensions, etc.). In addition, it can pass custom data down to all descendants. An important example of the latter is setting a value for enabled/disabled status so that an entire subtree can be disabled ("grayed out") with one setting.

Methods

impl Env[src]

pub fn get<'a, V: ValueType<'a>>(&'a self, key: Key<V>) -> V[src]

Gets a value from the environment, expecting it to be present.

Note that the return value is a reference for "expensive" types such as strings, but an ordinary value for "cheap" types such as numbers and colors.

Panics

Panics if the key is not found, or if it is present with the wrong type.

pub fn try_get<'a, V: ValueType<'a>>(&'a self, key: Key<V>) -> Option<V>[src]

Gets a value from the environment.

Panics

Panics if the value for the key is found, but has the wrong type.

pub fn adding<'a, V: ValueType<'a>>(
    self,
    key: Key<V>,
    value: impl Into<V::Owned>
) -> Env
[src]

Adds a key/value, acting like a builder.

pub fn set<'a, V: ValueType<'a>>(
    &'a mut self,
    key: Key<V>,
    value: impl Into<V::Owned>
)
[src]

Sets a value in an environment.

Panics

Panics if the environment already has a value for the key, but it is of a different type.

pub fn localization_manager(&self) -> &L10nManager[src]

Returns a reference to the L10nManager, which handles localization resources.

Trait Implementations

impl Data for Env[src]

impl Clone for Env[src]

impl Default for Env[src]

Auto Trait Implementations

impl Send for Env

impl Sync for Env

impl Unpin for Env

impl !UnwindSafe for Env

impl !RefUnwindSafe for Env

Blanket Implementations

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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

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

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

impl<T> RoundFrom<T> for T

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