Crate crockford [] [src]

Crockford

This library is intended to provide an easy way to encode and decode identifiers (large integers) as Crockford-encoded strings. If you want to encode or decode arbitrary data, another library is probably a better choice.

Encoding

Use the encode function to encode u64 values into Crockford Base32-encoded strings. This operation cannot fail, so you will always get back a string rather than any kind of result value.

let x = crockford::encode(5111);

assert_eq!("4ZQ", &*x);

Decoding

Use the decode function to decode Crockford Base32-encoded strings. This operation can fail; if it does, you'll get a reasonably useful error instead of a number.

let x = crockford::decode("4zq");
let y = crockford::decode("4ZQ");

assert_eq!(5111, x?);
assert_eq!(5111, y?);

Structs

Error

Represents an error in decoding.

Functions

decode

Attempts to decode a Crockford Base32-encoded string into a u64 value.

encode

Encodes a u64 value as a Crockford Base32-encoded string.