#[non_exhaustive]pub enum Value {
Void = 0,
Number(f64),
String(SharedString),
Bool(bool),
Image(Image),
Model(ModelRc<Value>),
Struct(Struct),
Brush(Brush),
Keys(Keys),
DataTransfer(DataTransfer),
}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 (Non-exhaustive)§
This enum is marked as non-exhaustive
Void = 0
There is nothing in this value. That’s the default. For example, a function that does 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
Keys(Keys)
Correspond to the keys type in .slint
DataTransfer(DataTransfer)
Correspond to the data-transfer type in .slint
Implementations§
Trait Implementations§
Source§impl From<DataTransfer> for Value
impl From<DataTransfer> for Value
Source§fn from(v: DataTransfer) -> Self
fn from(v: DataTransfer) -> Self
Source§impl From<LogicalPosition> for Value
impl From<LogicalPosition> for Value
Source§fn from(_: LogicalPosition) -> Self
fn from(_: LogicalPosition) -> Self
Source§impl From<LogicalSize> for Value
impl From<LogicalSize> for Value
Source§fn from(_: LogicalSize) -> Self
fn from(_: LogicalSize) -> Self
Source§fn from(v: SharedString) -> Self
fn from(v: SharedString) -> Self
Source§fn from(v: SharedVector<f32>) -> Self
fn from(v: SharedVector<f32>) -> Self
Source§fn from(v: SharedVector<u16>) -> Self
fn from(v: SharedVector<u16>) -> Self
Source§impl InterpolatedPropertyValue for Value
Animated bindings on sub-component properties need Value to support
interpolation. Numeric and brush variants interpolate; everything else
snaps. Numbers interpolate in f32 because animated numeric properties
are f32-based — an f64 blend would leak rounding noise like
99.50000001117587 instead of 99.5.
impl InterpolatedPropertyValue for Value
Animated bindings on sub-component properties need Value to support
interpolation. Numeric and brush variants interpolate; everything else
snaps. Numbers interpolate in f32 because animated numeric properties
are f32-based — an f64 blend would leak rounding noise like
99.50000001117587 instead of 99.5.
Source§fn interpolate(&self, target: &Self, t: f32) -> Self
fn interpolate(&self, target: &Self, t: f32) -> Self
Source§impl TryFrom<Value> for DataTransfer
impl TryFrom<Value> for DataTransfer
Source§impl TryFrom<Value> for LogicalPosition
impl TryFrom<Value> for LogicalPosition
Source§impl TryFrom<Value> for LogicalSize
impl TryFrom<Value> for LogicalSize
impl ValueType for Value
Auto Trait Implementations§
impl !RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl !UnwindSafe for Value
impl Freeze for Value
impl Unpin for Value
impl UnsafeUnpin for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Brush for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.