LoadingWidgets

Struct LoadingWidgets 

Source
pub struct LoadingWidgets { /* private fields */ }
Expand description

A type that stores widget containers and their child widgets and removes all children automatically when dropped.

This mechanism is used by async components and factories to show widgets while the async init function isn’t completed. Once the actual widgets are initialized, the temporary loading widgets can be removed again, which is simply done with this type.

Implementations§

Source§

impl LoadingWidgets

Source

pub fn new<C, W>(container: C, child: W) -> Self
where C: RelmRemoveExt + 'static, W: AsRef<C::Child>, C::Child: Clone + AsRef<C::Child>,

Create new LoadingWidgets with one child.

Examples found in repository?
relm4/examples/simple_async.rs (line 70)
54    fn init_loading_widgets(root: Self::Root) -> Option<LoadingWidgets> {
55        view! {
56            #[local]
57            root {
58                set_title: Some("Simple app"),
59                set_default_size: (300, 100),
60
61                // This will be removed automatically by
62                // LoadingWidgets when the full view has loaded
63                #[name(spinner)]
64                gtk::Spinner {
65                    start: (),
66                    set_halign: gtk::Align::Center,
67                }
68            }
69        }
70        Some(LoadingWidgets::new(root, spinner))
71    }
More examples
Hide additional examples
relm4/examples/factory_async.rs (line 108)
91    fn init_loading_widgets(root: Self::Root) -> Option<LoadingWidgets> {
92        view! {
93            #[local]
94            root {
95                set_orientation: gtk::Orientation::Horizontal,
96                set_spacing: 10,
97
98                #[name(spinner)]
99                gtk::Spinner {
100                    start: (),
101                    set_hexpand: true,
102                    set_halign: gtk::Align::Center,
103                    // Reserve vertical space
104                    set_height_request: 34,
105                }
106            }
107        }
108        Some(LoadingWidgets::new(root, spinner))
109    }
Source

pub fn with_children<C, W>(container: C, children: &[W]) -> Self
where C: RelmRemoveExt + 'static, W: AsRef<C::Child>, C::Child: Clone + AsRef<C::Child>,

Create new LoadingWidgets with multiple children.

Source

pub fn push<C, W>(&mut self, container: C, child: W)
where C: RelmRemoveExt + 'static, W: AsRef<C::Child>, C::Child: Clone + AsRef<C::Child>,

Add another child to the temporary loading widgets.

Source

pub fn add_many<C, W>(&mut self, container: C, children: &[W])
where C: RelmRemoveExt + 'static, W: AsRef<C::Child>, C::Child: Clone + AsRef<C::Child>,

Add many children to the temporary loading widgets.

Trait Implementations§

Source§

impl Debug for LoadingWidgets

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for LoadingWidgets

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<C> AsyncPosition<()> for C

Source§

fn position(_index: usize)

Returns the position. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<C, I> Position<(), I> for C

Source§

fn position(&self, _index: &I)

Returns the position. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more