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§
Trait Implementations§
source§fn from(v: SharedString) -> Self
fn from(v: SharedString) -> Self
Converts to this type from the input type.
source§fn from(v: SharedVector<f32>) -> Self
fn from(v: SharedVector<f32>) -> Self
Converts to this type from the input type.
source§impl PartialEq<Value> for Value
impl PartialEq<Value> for Value
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> 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
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
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>
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)
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)
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§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
The none-equivalent value.
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for Pwhere
R: Read + ReadEndian<P>,
P: Default,
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>
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()
.