Enum slint_interpreter::Value

source ยท
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<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(_: KeyEvent) -> Self

Converts to this type from the input type.
sourceยง

impl From<KeyboardModifiers> for Value

sourceยง

fn from(_: 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<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(_: 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(_: StandardListViewItem) -> Self

Converts to this type from the input type.
sourceยง

impl From<StateInfo> for Value

sourceยง

fn from(_: 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(_: 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 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 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ยง

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>) -> 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.
ยง

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 = mem::align_of::<T>()

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