GenUI data types

GenUI abstracts data types and divides them into 11 types:

  • USize: unsigned integer
  • ISize: signed integer
  • Double: floating point type, including f32 and f64
  • Bool: Boolean type
  • Vec: vector
  • String: string
  • Bind: binding
  • Function: method
  • Struct: structure
  • Enum: enumeration
  • Unknown: unknown

This does not mean that you need to use these types, but GenUI will abstract the types of the attribute values ​​involved when parsing. You only need to pay attention to how to use them in the template.

TIP

For more specific built-in data types, please refer to: Data API

Value parsing and writing

  • template: Indicates how to use it in the <template> tag
  • style: Indicates how to use it in the <style> tag
valueparsed type
10USize(10)
-10ISize(-10)
10.0Double(10.0)
trueBool(true)
[10, 12]Vec[USize(10), USize(12)]
'Hello' templateString("Hello")
"Hello" styleString("Hello")
:age="user_age" templateBind([Ident("user_age")])
@clicked="click_btn()" templateFunction{ name:"click_btn", params: None}
color: rgb(12, 0, 255) styleFunction{ name:"rgb", params: [USize(12), USize(0), USize(255)]}
{x: 0.5}Struct{ name: None, fields: {"x": Double(0.5)} }
DarkEnum{ field_chain: [EnumItem::Leaf("Dark", None)] }
Themes::DarkEnum{ field_chain: [EnumItem::Root("Themes"), EnumItem::Leaf("Dark", None)] }
12.0 10.0Unknown("12.0 10.0")
Table of Contents