pub enum Value {
    Void,
    Number(f64),
    String(SharedString),
    Bool(bool),
    Image(Image),
    Model(ModelRc<Value>),
    Struct(Struct),
    Brush(Brush),
    // some variants omitted
}
Expand description

This is a dynamically typed value used in the Slint interpreter. It can hold a value of different types, and you should use the From or TryFrom traits to access the value.

use core::convert::TryInto;
// create a value containing an integer
let v = Value::from(100u32);
assert_eq!(v.try_into(), Ok(100u32));

Variants§

§

Void

There is nothing in this value. That’s the default. For example, a function that do not return a result would return a Value::Void

§

Number(f64)

An int or a float (this is also used for unit based type such as length or angle)

§

String(SharedString)

Correspond to the string type in .slint

§

Bool(bool)

Correspond to the bool type in .slint

§

Image(Image)

Correspond to the image type in .slint

§

Model(ModelRc<Value>)

A model (that includes array in .slint)

§

Struct(Struct)

An object

§

Brush(Brush)

Correspond to brush or color type in .slint. For color, this is then a Brush::SolidColor

Implementations§

source§

impl Value

source

pub fn value_type(&self) -> ValueType

Returns the type variant that this value holds without the containing value.

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

Returns a copy 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 Value

source§

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

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

impl Default for Value

source§

fn default() -> Value

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

impl From<()> for Value

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl From<AccessibleRole> for Value

source§

fn from(v: AccessibleRole) -> Self

Converts to this type from the input type.
source§

impl From<Brush> for Value

source§

fn from(v: Brush) -> Self

Converts to this type from the input type.
source§

impl From<Color> for Value

source§

fn from(c: Color) -> Self

Converts to this type from the input type.
source§

impl From<ComponentFactory> for Value

source§

fn from(v: ComponentFactory) -> Self

Converts to this type from the input type.
source§

impl From<DialogButtonRole> for Value

source§

fn from(v: DialogButtonRole) -> Self

Converts to this type from the input type.
source§

impl From<EasingCurve> for Value

source§

fn from(v: EasingCurve) -> Self

Converts to this type from the input type.
source§

impl From<EventResult> for Value

source§

fn from(v: EventResult) -> Self

Converts to this type from the input type.
source§

impl From<FillRule> for Value

source§

fn from(v: FillRule) -> Self

Converts to this type from the input type.
source§

impl From<Image> for Value

source§

fn from(v: Image) -> Self

Converts to this type from the input type.
source§

impl From<ImageFit> for Value

source§

fn from(v: ImageFit) -> Self

Converts to this type from the input type.
source§

impl From<ImageRendering> for Value

source§

fn from(v: ImageRendering) -> Self

Converts to this type from the input type.
source§

impl From<InputType> for Value

source§

fn from(v: InputType) -> Self

Converts to this type from the input type.
source§

impl From<Instant> for Value

source§

fn from(value: Instant) -> Self

Converts to this type from the input type.
source§

impl From<KeyEvent> for Value

source§

fn from(item: KeyEvent) -> Self

Converts to this type from the input type.
source§

impl From<KeyboardModifiers> for Value

source§

fn from(item: KeyboardModifiers) -> Self

Converts to this type from the input type.
source§

impl From<LayoutAlignment> for Value

source§

fn from(v: LayoutAlignment) -> Self

Converts to this type from the input type.
source§

impl From<LayoutInfo> for Value

source§

fn from(_: LayoutInfo) -> Self

Converts to this type from the input type.
source§

impl From<Length<f32, LogicalPx>> for Value

source§

fn from(l: LogicalLength) -> Self

Converts to this type from the input type.
source§

impl From<MouseCursor> for Value

source§

fn from(v: MouseCursor) -> Self

Converts to this type from the input type.
source§

impl From<Orientation> for Value

source§

fn from(v: Orientation) -> Self

Converts to this type from the input type.
source§

impl From<PathData> for Value

source§

fn from(v: PathData) -> Self

Converts to this type from the input type.
source§

impl From<PathEvent> for Value

source§

fn from(v: PathEvent) -> Self

Converts to this type from the input type.
source§

impl From<Point2D<f32, UnknownUnit>> for Value

source§

fn from(_: Point) -> Self

Converts to this type from the input type.
source§

impl From<PointerEvent> for Value

source§

fn from(item: PointerEvent) -> Self

Converts to this type from the input type.
source§

impl From<PointerEventButton> for Value

source§

fn from(v: PointerEventButton) -> Self

Converts to this type from the input type.
source§

impl From<PointerEventKind> for Value

source§

fn from(v: PointerEventKind) -> Self

Converts to this type from the input type.
source§

impl From<SharedString> for Value

source§

fn from(v: SharedString) -> Self

Converts to this type from the input type.
source§

impl From<SharedVector<f32>> for Value

source§

fn from(v: SharedVector<f32>) -> Self

Converts to this type from the input type.
source§

impl From<SortOrder> for Value

source§

fn from(v: SortOrder) -> Self

Converts to this type from the input type.
source§

impl From<StandardButtonKind> for Value

source§

fn from(v: StandardButtonKind) -> Self

Converts to this type from the input type.
source§

impl From<StandardListViewItem> for Value

source§

fn from(item: StandardListViewItem) -> Self

Converts to this type from the input type.
source§

impl From<StateInfo> for Value

source§

fn from(item: StateInfo) -> Self

Converts to this type from the input type.
source§

impl From<Struct> for Value

source§

fn from(v: Struct) -> Self

Converts to this type from the input type.
source§

impl From<TableColumn> for Value

source§

fn from(item: TableColumn) -> Self

Converts to this type from the input type.
source§

impl From<TextHorizontalAlignment> for Value

source§

fn from(v: TextHorizontalAlignment) -> Self

Converts to this type from the input type.
source§

impl From<TextOverflow> for Value

source§

fn from(v: TextOverflow) -> Self

Converts to this type from the input type.
source§

impl From<TextVerticalAlignment> for Value

source§

fn from(v: TextVerticalAlignment) -> Self

Converts to this type from the input type.
source§

impl From<TextWrap> for Value

source§

fn from(v: TextWrap) -> Self

Converts to this type from the input type.
source§

impl From<bool> for Value

source§

fn from(v: bool) -> Self

Converts to this type from the input type.
source§

impl From<f32> for Value

source§

fn from(v: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for Value

source§

fn from(v: f64) -> Self

Converts to this type from the input type.
source§

impl From<i32> for Value

source§

fn from(v: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for Value

source§

fn from(v: i64) -> Self

Converts to this type from the input type.
source§

impl From<isize> for Value

source§

fn from(v: isize) -> Self

Converts to this type from the input type.
source§

impl From<u32> for Value

source§

fn from(v: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for Value

source§

fn from(v: u64) -> Self

Converts to this type from the input type.
source§

impl From<usize> for Value

source§

fn from(v: usize) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Value> for Value

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Value> for ()

§

type Error = ()

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

fn try_from(_: Value) -> Result<(), Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for AccessibleRole

§

type Error = ()

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

fn try_from(v: Value) -> Result<AccessibleRole, ()>

Performs the conversion.
source§

impl TryFrom<Value> for Brush

§

type Error = Value

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

fn try_from(v: Value) -> Result<Brush, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for Color

§

type Error = Value

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

fn try_from(v: Value) -> Result<Color, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for ComponentFactory

§

type Error = Value

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

fn try_from(v: Value) -> Result<ComponentFactory, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for DialogButtonRole

§

type Error = ()

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

fn try_from(v: Value) -> Result<DialogButtonRole, ()>

Performs the conversion.
source§

impl TryFrom<Value> for EasingCurve

§

type Error = Value

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

fn try_from(v: Value) -> Result<EasingCurve, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for EventResult

§

type Error = ()

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

fn try_from(v: Value) -> Result<EventResult, ()>

Performs the conversion.
source§

impl TryFrom<Value> for FillRule

§

type Error = ()

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

fn try_from(v: Value) -> Result<FillRule, ()>

Performs the conversion.
source§

impl TryFrom<Value> for Image

§

type Error = Value

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

fn try_from(v: Value) -> Result<Image, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for ImageFit

§

type Error = ()

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

fn try_from(v: Value) -> Result<ImageFit, ()>

Performs the conversion.
source§

impl TryFrom<Value> for ImageRendering

§

type Error = ()

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

fn try_from(v: Value) -> Result<ImageRendering, ()>

Performs the conversion.
source§

impl TryFrom<Value> for InputType

§

type Error = ()

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

fn try_from(v: Value) -> Result<InputType, ()>

Performs the conversion.
source§

impl TryFrom<Value> for Instant

§

type Error = ()

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

fn try_from(v: Value) -> Result<Instant, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for KeyEvent

§

type Error = ()

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

fn try_from(v: Value) -> Result<KeyEvent, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for KeyboardModifiers

§

type Error = ()

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

fn try_from(v: Value) -> Result<KeyboardModifiers, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for LayoutAlignment

§

type Error = ()

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

fn try_from(v: Value) -> Result<LayoutAlignment, ()>

Performs the conversion.
source§

impl TryFrom<Value> for LayoutInfo

§

type Error = ()

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

fn try_from(v: Value) -> Result<LayoutInfo, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for LogicalLength

§

type Error = Value

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

fn try_from(v: Value) -> Result<LogicalLength, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for MouseCursor

§

type Error = ()

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

fn try_from(v: Value) -> Result<MouseCursor, ()>

Performs the conversion.
source§

impl TryFrom<Value> for Orientation

§

type Error = ()

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

fn try_from(v: Value) -> Result<Orientation, ()>

Performs the conversion.
source§

impl TryFrom<Value> for PathData

§

type Error = Value

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

fn try_from(v: Value) -> Result<PathData, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for PathEvent

§

type Error = ()

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

fn try_from(v: Value) -> Result<PathEvent, ()>

Performs the conversion.
source§

impl TryFrom<Value> for Point

§

type Error = ()

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

fn try_from(v: Value) -> Result<Point, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for PointerEvent

§

type Error = ()

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

fn try_from(v: Value) -> Result<PointerEvent, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for PointerEventButton

§

type Error = ()

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

fn try_from(v: Value) -> Result<PointerEventButton, ()>

Performs the conversion.
source§

impl TryFrom<Value> for PointerEventKind

§

type Error = ()

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

fn try_from(v: Value) -> Result<PointerEventKind, ()>

Performs the conversion.
source§

impl TryFrom<Value> for SharedString

§

type Error = Value

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

fn try_from(v: Value) -> Result<SharedString, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for SharedVector<f32>

§

type Error = Value

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

fn try_from(v: Value) -> Result<SharedVector<f32>, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for SortOrder

§

type Error = ()

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

fn try_from(v: Value) -> Result<SortOrder, ()>

Performs the conversion.
source§

impl TryFrom<Value> for StandardButtonKind

§

type Error = ()

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

fn try_from(v: Value) -> Result<StandardButtonKind, ()>

Performs the conversion.
source§

impl TryFrom<Value> for StandardListViewItem

§

type Error = ()

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

fn try_from(v: Value) -> Result<StandardListViewItem, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for StateInfo

§

type Error = ()

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

fn try_from(v: Value) -> Result<StateInfo, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for Struct

§

type Error = Value

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

fn try_from(v: Value) -> Result<Struct, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for TableColumn

§

type Error = ()

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

fn try_from(v: Value) -> Result<TableColumn, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for TextHorizontalAlignment

§

type Error = ()

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

fn try_from(v: Value) -> Result<TextHorizontalAlignment, ()>

Performs the conversion.
source§

impl TryFrom<Value> for TextOverflow

§

type Error = ()

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

fn try_from(v: Value) -> Result<TextOverflow, ()>

Performs the conversion.
source§

impl TryFrom<Value> for TextVerticalAlignment

§

type Error = ()

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

fn try_from(v: Value) -> Result<TextVerticalAlignment, ()>

Performs the conversion.
source§

impl TryFrom<Value> for TextWrap

§

type Error = ()

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

fn try_from(v: Value) -> Result<TextWrap, ()>

Performs the conversion.
source§

impl TryFrom<Value> for bool

§

type Error = Value

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

fn try_from(v: Value) -> Result<bool, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for f32

§

type Error = Value

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

fn try_from(v: Value) -> Result<f32, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for f64

§

type Error = Value

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

fn try_from(v: Value) -> Result<f64, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for i32

§

type Error = Value

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

fn try_from(v: Value) -> Result<i32, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for i64

§

type Error = Value

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

fn try_from(v: Value) -> Result<i64, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for isize

§

type Error = Value

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

fn try_from(v: Value) -> Result<isize, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for u32

§

type Error = Value

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

fn try_from(v: Value) -> Result<u32, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for u64

§

type Error = Value

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

fn try_from(v: Value) -> Result<u64, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for usize

§

type Error = Value

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

fn try_from(v: Value) -> Result<usize, Self::Error>

Performs the conversion.
source§

impl ValueType for Value

Auto Trait Implementations§

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin for Value

§

impl !UnwindSafe for Value

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for Twhere T: Any,

§

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

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.
§

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

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

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.
§

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> 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 Twhere 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.

§

impl<T> NoneValue for Twhere T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<R, P> ReadPrimitive<R> for Pwhere R: Read + ReadEndian<P>, P: Default,

source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

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