strkey
strkey is Rust library for serialization of values into an human-readable encoding that preserves lexicographic sort order. The encoded format is useful for key-value stores/databases that maintains keys in sorted order.
This crate is similar to bytekey/bytekey-fix/bytekey2 except those this crate encodes into a human-readable, UTF-8 encoded string.
Most data types in the Serde data model are supported. The encoding consists of each encoded value separated by a deliminator (a colon :
by default). Integers, floats, and byte arrays are encoded in hexadecimal while strings are left as is in UTF-8. Full details are listed in the documentation in the ser
module. Note that the encoding is not self-describing, that is, types are not encoded within the format.
Quick start
Remember to add strkey
to your Cargo.toml first.
let serialized = to_vec?;
assert_eq!;
let deserialized = ?;
assert_eq!;
assert_eq!;
More complicated schemas can be modelled: (Enable the derive
feature in serde if needed.)
use ;
let serialized = to_vec?;
assert_eq!;
let deserialized = ?;
assert_eq!;
assert_eq!;
Contributing
If you have any issues or features, please use the GitHub Issues and Pull Request sections.
License
Copyright 2021 Christopher Foo. Licensed under MPL-2.0.