Enum WidgetRef

Source
pub enum WidgetRef {
    None,
    Owned(Rc<dyn Widget>),
    Borrowed(Weak<dyn Widget>),
    Keyed {
        owner_id: Option<WidgetId>,
        key: Key,
        widget: Box<WidgetRef>,
    },
}
Expand description

Holds a reference to a widget, or not.

This is generally used when a widget can accept children as a parameter. It can either be Owned, Borrowed, None, or Keyed. A Keyed widget is one that may retain its state across parental rebuilds.

Variants§

§

None

No widget.

§

Owned(Rc<dyn Widget>)

An owned widget.

§

Borrowed(Weak<dyn Widget>)

A borrowed widget.

§

Keyed

A keyed reference which may retain its state across parental rebuilds.

Fields

§owner_id: Option<WidgetId>
§key: Key
§widget: Box<WidgetRef>

Implementations§

Source§

impl WidgetRef

Source

pub fn new<W>(widget: W) -> WidgetRef
where W: Widget,

Source

pub fn is_valid(&self) -> bool

Returns true if the widget is still allocated in memory.

Source

pub fn try_get(&self) -> Option<Rc<dyn Widget>>

Source

pub fn get(&self) -> Rc<dyn Widget>

§Panics

Will panic if the widget no longer exists, or the reference is empty.

Source

pub fn get_type_id(&self) -> TypeId

§Panics

Will panic if the widget no longer exists, or the reference is empty.

Source

pub fn get_type_name(&self) -> &'static str

§Panics

Will panic if the widget no longer exists, or the reference is empty.

Source

pub fn try_downcast_ref<W>(&self) -> Option<Rc<W>>
where W: Widget,

Returns none of the widget is not the W type, or if it has been deallocated.

Source

pub fn downcast_ref<W>(&self) -> Rc<W>
where W: Widget,

§Panics

Will panic if the widget cannot be downcasted to the generic type.

Trait Implementations§

Source§

impl Clone for WidgetRef

Source§

fn clone(&self) -> WidgetRef

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WidgetRef

Source§

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

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

impl Default for WidgetRef

Source§

fn default() -> WidgetRef

Returns the “default value” for a type. Read more
Source§

impl From<&WidgetRef> for BuildResult

Source§

fn from(widget: &WidgetRef) -> BuildResult

Converts to this type from the input type.
Source§

impl From<&WidgetRef> for WidgetRef

Source§

fn from(widget: &WidgetRef) -> WidgetRef

Converts to this type from the input type.
Source§

impl From<App> for WidgetRef

Source§

fn from(widget: App) -> WidgetRef

Converts to this type from the input type.
Source§

impl<F> From<Builder<F>> for WidgetRef
where F: Fn(&WidgetContext<'_>) -> BuildResult + 'static,

Source§

fn from(builder: Builder<F>) -> WidgetRef

Converts to this type from the input type.
Source§

impl From<Button> for WidgetRef

Source§

fn from(widget: Button) -> WidgetRef

Converts to this type from the input type.
Source§

impl From<Column> for WidgetRef

Source§

fn from(widget: Column) -> WidgetRef

Converts to this type from the input type.
Source§

impl From<Drawable> for WidgetRef

Source§

fn from(widget: Drawable) -> WidgetRef

Converts to this type from the input type.
Source§

impl From<Padding> for WidgetRef

Source§

fn from(widget: Padding) -> WidgetRef

Converts to this type from the input type.
Source§

impl From<Row> for WidgetRef

Source§

fn from(widget: Row) -> WidgetRef

Converts to this type from the input type.
Source§

impl From<Spacing> for WidgetRef

Source§

fn from(widget: Spacing) -> WidgetRef

Converts to this type from the input type.
Source§

impl From<Text> for WidgetRef

Source§

fn from(widget: Text) -> WidgetRef

Converts to this type from the input type.
Source§

impl From<WidgetRef> for BuildResult

Source§

fn from(widget: WidgetRef) -> BuildResult

Converts to this type from the input type.
Source§

impl Into<Vec<WidgetRef>> for WidgetRef

Source§

fn into(self) -> Vec<WidgetRef>

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

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V