Expand description
Value: the plain-data payload type for everything that crosses an
event or binding boundary.
A click payload, a drag event’s fields, a readback for a script: all of
them are a Value, so Rust, Lua, Node and C see one shape. A Rust app
that wants an exhaustive match over its own payloads puts a typed
enum on top with crate::message.
use kui_core::Value;
let v = Value::map([
("kind", Value::str("drag")),
("x", Value::from(1.5f32)),
("n", Value::from(4usize)),
("on", true.into()),
]);
assert_eq!(v.get_str("kind"), Some("drag"));
assert_eq!(v.get_f32("x"), Some(1.5));
assert_eq!(v.get_float("n"), Some(4.0)); // an int reads as a float
assert_eq!(v.get_str("x"), None); // the wrong type is None
assert_eq!(Value::from("save"), Value::Str("save".into()));Structs§
- Handles
- How a binding spells the handles inside a readback (a node key, a
resource id) when a shape crosses as a
Value. A JS number cannot hold a 64-bit handle and a Lua integer can, so Node writes sixteen hex digits (Handles::HEX) and Lua the integer itself (Handles::INT).
Enums§
- Value
- A dynamically typed value: null, bool, int, float, string, list or an ordered string-keyed map. See the module docs for an example.