Crate kle_serial

Source
Expand description

A Rust library for deserialising Keyboard Layout Editor files. Designed to be used in conjunction with serde_json to deserialize JSON files exported from KLE.

§Example

example

use kle_serial::Keyboard; // Equivalent to kle_serial::Keyboard<f64> or kle_serial::f64::Keyboard

let keyboard: Keyboard = serde_json::from_str(
    r#"[
        {"name": "example"},
        [{"f": 4}, "!\n1\n¹\n¡"]
    ]"#
).unwrap();

assert_eq!(keyboard.metadata.name, "example");
assert_eq!(keyboard.keys.len(), 1);

assert!(keyboard.keys[0].legends[0].is_some());
let legend = keyboard.keys[0].legends[0].as_ref().unwrap();

assert_eq!(legend.text, "!");
assert_eq!(legend.size, 4);

assert!(keyboard.keys[0].legends[1].is_none());

Modules§

f32
Type aliases of all public kle-serial types using f32 for any generic parameters
f64
Type aliases of all public kle-serial types using f64 for any generic parameters

Structs§

Background
The background style of a KLE layout.
Key
A struct representing a single key.
KeyIterator
An iterator of Keys deserialised from a KLE JSON file.
Keyboard
A keyboard deserialised from a KLE JSON file.
Legend
A struct representing a single legend.
Metadata
The metadata for the keyboard layout.
Switch
A struct representing a key switch.

Type Aliases§

Color
Colour type used for deserialising. Type alias of rgb::RGBA8.