Crate boba

source ·
Expand description

This crate provides an implementation of a Bubble Babble encoder and decoder.

The Bubble Babble encoding uses alternation of consonants and vowels to encode binary data to pseudowords that can be pronounced more easily than arbitrary lists of hexadecimal digits.

Bubble Babble is part of the Digest libraries in Perl and Ruby.

§Usage

You can encode binary data by calling encode:

let encoded = boba::encode("Pineapple");
assert_eq!(encoded, "xigak-nyryk-humil-bosek-sonax");

Decoding binary data is done by calling decode:

let decoded = boba::decode("xexax")?;
assert_eq!(decoded, vec![]);

Decoding data is fallible and can return DecodeError. For example, all Bubble Babble–encoded data has an ASCII alphabet, so attempting to decode an emoji will fail.

let decoded = boba::decode("x🦀x");
// The `DecodeError` contains the offset of the first invalid byte.
assert_eq!(decoded, Err(DecodeError::InvalidByte(1)));

§Crate Features

Boba is no_std compatible with a required dependency on the alloc crate.

Boba has several Cargo features, all of which are enabled by default:

  • std - Adds a dependency on std, the Rust Standard Library. This feature enables std::error::Error implementations on error types in this crate. Enabling the std feature also enables the alloc feature.

Enums§

Functions§

  • Decode Bubble Babble-encoded byte slice to a Vec<u8>.
  • Encode a byte slice with the Bubble Babble encoding to a String.