logo

Struct iced::pure::Pure

source · []
pub struct Pure<'a, Message, Renderer> { /* private fields */ }
Available on crate feature pure only.
Expand description

A bridge between impure and pure widgets.

If you already have an existing iced application, you do not need to switch completely to the new traits in order to benefit from the pure module. Instead, you can leverage the new Pure widget to include pure widgets in your impure Application.

For instance, let’s say we want to use our pure Counter in an impure application:

use iced_pure::{self, Pure};

struct Impure {
    state: pure::State,
    counter: Counter,
}

impl Sandbox for Impure {
    // ...

    pub fn view(&mut self) -> Element<Self::Message> {
        Pure::new(&mut self.state, self.counter.view()).into()
    }
}

Pure acts as a bridge between pure and impure widgets. It is completely opt-in and can be used to slowly migrate your application to the new architecture.

The purification of your application may trigger a bunch of important refactors, since it’s far easier to keep your data decoupled from the GUI state with stateless widgets. For this reason, I recommend starting small in the most nested views of your application and slowly expand the purity upwards.

Implementations

Creates a new Pure widget with the given State and impure Element.

Trait Implementations

Converts this type into the (usually inferred) input type.

Returns the width of the Widget.

Returns the height of the Widget.

Returns the Node of the Widget. Read more

Processes a runtime Event. Read more

Draws the Widget using the associated Renderer.

Returns the current mouse::Interaction of the Widget. Read more

Returns the overlay of the Widget, if there is any.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.