kle-serial

Crates.iokle-serial
lib.rskle-serial
version0.3.2
created_at2023-07-15 00:28:59.748795+00
updated_at2025-08-12 23:50:28.115911+00
descriptionRust deserialisation library for Keyboard Layout Editor JSON files
homepage
repositoryhttps://github.com/staticintlucas/kle-serial-rs
max_upload_size
id916873
size78,489
Lucas Jansen (staticintlucas)

documentation

README

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

// kle_serial::Keyboard uses f64 coordinates by default. If you need f32 coordinates use
// kle_serial::Keyboard<f32> or kle_serial::f32::Keyboard instead.
use kle_serial::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.

Commit count: 57

cargo fmt