#urbit #decode #encode-decode #format #data #byte

urbit-q

Encode and decode data in Urbit's @q format

12 releases

0.3.2 Jun 22, 2020
0.3.1 Jun 17, 2020
0.2.6 Jun 17, 2020
0.1.2 Jun 16, 2020

#5 in #urbit

49 downloads per month

MIT license

23KB
110 lines

urbit-q

Based on urbit-ob, supports only the @q format.

usage

Note that when encoding more than one byte, encode pads from the beginning to an even number of bytes (as per the original implementation) and decode ignores any dashes, tildes or spaces within the string.

urbit_q::encode(&[1]); // nec
let string = urbit_q::encode(&[1, 2, 3]); // doznec-binwes
urbit_q::decode(&string).unwrap(); // [0, 1, 2, 3]
urbit_q::decode("doz nec bin wes"); // Some([0, 1, 2, 3])
urbit_q::decode("do-z ne cb~inwes"); // Some([0, 1, 2, 3])
urbit_q::decode("nec-binwes"); // Some([1, 2, 3])
urbit_q::decode("hello world"); // None

lib.rs:

urbit-q

Based on urbit-ob, supports only the @q format.

usage

Note that when encoding more than one byte, encode pads from the beginning to an even number of bytes (as per the original implementation) and decode ignores any dashes, tildes or spaces within the string.

urbit_q::encode(&[1]); // nec
let string = urbit_q::encode(&[1, 2, 3]); // doznec-binwes
urbit_q::decode(&string).unwrap(); // [0, 1, 2, 3]
urbit_q::decode("doz nec bin wes"); // Some([0, 1, 2, 3])
urbit_q::decode("do-z ne cb~inwes"); // Some([0, 1, 2, 3])
urbit_q::decode("nec-binwes"); // Some([1, 2, 3])
urbit_q::decode("hello world"); // None

Dependencies

~2MB
~46K SLoC