#keyboard-layout #keyboard #layout #key-set #deserialize-json #kle #keycap

kle-serial

Rust deserialisation library for Keyboard Layout Editor JSON files

7 releases

0.3.1 Dec 7, 2024
0.3.0 Sep 27, 2023
0.2.2 Aug 6, 2023
0.2.1 Jul 26, 2023
0.1.1 Jul 22, 2023

#780 in Encoding

Download history 45/week @ 2024-09-02 23/week @ 2024-09-23 22/week @ 2024-10-07 6/week @ 2024-10-14 4/week @ 2024-10-28 118/week @ 2024-12-02 106/week @ 2024-12-09

224 downloads per month
Used in 2 crates (via keyset-key)

MIT/Apache

56KB
1.5K SLoC

kle-serial   Test Status Test Coverage Crate Version Rust Version

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());

Licence

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.6–1.3MB
~27K SLoC