Enum i_slint_compiler::langtype::Type
source · pub enum Type {
Show 29 variants
Invalid,
Void,
InferredProperty,
InferredCallback,
Callback {
return_type: Option<Box<Type>>,
args: Vec<Type>,
},
Function {
return_type: Box<Type>,
args: Vec<Type>,
},
ComponentFactory,
Float32,
Int32,
String,
Color,
Duration,
PhysicalLength,
LogicalLength,
Rem,
Angle,
Percent,
Image,
Bool,
Model,
PathData,
Easing,
Brush,
Array(Box<Type>),
Struct {
fields: BTreeMap<String, Type>,
name: Option<String>,
node: Option<ObjectType>,
rust_attributes: Option<Vec<String>>,
},
Enumeration(Rc<Enumeration>),
UnitProduct(Vec<(Unit, i8)>),
ElementReference,
LayoutCache,
}
Variants§
Invalid
Correspond to an uninitialized type, or an error
Void
The type of an expression that return nothing
InferredProperty
The type of a property two way binding whose type was not yet inferred
InferredCallback
The type of a callback alias whose type was not yet inferred
Callback
Function
ComponentFactory
Float32
Int32
String
Color
Duration
PhysicalLength
LogicalLength
Rem
Angle
Percent
Image
Bool
Model
Fake type that can represent anything that can be converted into a model.
PathData
Easing
Brush
Array(Box<Type>)
This is usually a model
Struct
Fields
name: Option<String>
When declared in .slint as struct Foo := { }
, then the name is “Foo”
When there is no node, but there is a name, then it is a builtin type
node: Option<ObjectType>
When declared in .slint, this is the node of the declaration.
Enumeration(Rc<Enumeration>)
UnitProduct(Vec<(Unit, i8)>)
A type made up of the product of several “unit” types. The first parameter is the unit, and the second parameter is the power. The vector should be sorted by 1) the power, 2) the unit.
ElementReference
LayoutCache
This is a SharedArray<f32>
Implementations§
source§impl Type
impl Type
sourcepub fn is_property_type(&self) -> bool
pub fn is_property_type(&self) -> bool
valid type for properties
pub fn ok_for_public_api(&self) -> bool
sourcepub fn as_enum(&self) -> &Rc<Enumeration>
pub fn as_enum(&self) -> &Rc<Enumeration>
Assume it is an enumeration, panic if it isn’t
sourcepub fn can_convert(&self, other: &Self) -> bool
pub fn can_convert(&self, other: &Self) -> bool
Return true if the type can be converted to the other type
sourcepub fn default_unit(&self) -> Option<Unit>
pub fn default_unit(&self) -> Option<Unit>
If this is a number type which should be used with an unit, this returns the default unit otherwise, returns None