Skip to content

Commit

Permalink
Merge pull request #28 from artichoke/boba-rebrand
Browse files Browse the repository at this point in the history
Rebrand crate to boba
  • Loading branch information
lopopolo authored Mar 23, 2020
2 parents 2cf8da0 + f36aa9e commit 1ca96db
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 49 deletions.
13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
[package]
name = "bubblebabble"
name = "boba"
version = "2.0.0" # remember to set `html_root_url` in `src/lib.rs`.
authors = ["Ryan Lopopolo <[email protected]>"]
license = "MIT"
edition = "2018"
readme = "README.md"
repository = "https://github.com/artichoke/bubblebabble"
homepage = "https://github.com/artichoke/bubblebabble"
repository = "https://github.com/artichoke/boba"
documentation = "https://docs.rs/boba"
homepage = "https://github.com/artichoke/boba"
description = "Encoder and decoder for the Bubble Babble binary data encoding"
keywords = ["encode", "decode", "utf8", "bubblebabble"]
categories = ["encoding"]
exclude = [
".github",
".gitignore",
"deny.toml",
"fuzz",
]

[features]
default = ["std"]
Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# bubblebabble
# boba

[![GitHub Actions](https://github.com/artichoke/bubblebabble/workflows/CI/badge.svg)](https://github.com/artichoke/bubblebabble/actions)
[![GitHub Actions](https://github.com/artichoke/boba/workflows/CI/badge.svg)](https://github.com/artichoke/boba/actions)
[![Discord](https://img.shields.io/discord/607683947496734760)](https://discord.gg/QCe2tp2)
[![Twitter](https://img.shields.io/twitter/follow/artichokeruby?label=Follow&style=social)](https://twitter.com/artichokeruby)
<br>
[![API master](https://img.shields.io/badge/docs-master-blue.svg)](https://artichoke.github.io/bubblebabble/bubblebabble/)
[![Crate](https://img.shields.io/crates/v/boba.svg)](https://crates.io/crates/boba)
[![API](https://docs.rs/boba/badge.svg)](https://docs.rs/boba)
[![API master](https://img.shields.io/badge/docs-master-blue.svg)](https://artichoke.github.io/boba/boba/)

Implements the the
[Bubble Babble binary data encoding](/spec/Bubble_Babble_Encoding.txt).
Expand All @@ -14,7 +16,7 @@ Implements the the
Bubble Babble encodes 6 characters in 16 bits and includes a checksum embedded
in the encoded data. See the
[Bubble Babble spec](/spec/Bubble_Babble_Encoding.txt).
[Bubble Babble spec](spec/Bubble_Babble_Encoding.txt).

This crate depends on [bstr](https://crates.io/crates/bstr).

Expand All @@ -24,24 +26,24 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
bubblebabble = "2"
boba = "2"
```

Then encode and decode data like:

```rust
assert_eq!(bubblebabble::encode("Pineapple"), "xigak-nyryk-humil-bosek-sonax");
assert_eq!(bubblebabble::decode(b"xexax"), Ok(vec![]));
assert_eq!(boba::encode("Pineapple"), "xigak-nyryk-humil-bosek-sonax");
assert_eq!(boba::decode(b"xexax"), Ok(vec![]));
```

## Crate Features

`bubblebabble` has a `std` feature which is enabled by default that adds `Vec`
and `String` support as well as `std::error::Error` impls. `bubblebabble` does
not compile if this feature is disabled, but exists so this crate can add
`no_std` support backwards compatibly.
`boba` has a `std` feature which is enabled by default that adds `Vec` and
`String` support as well as `std::error::Error` impls. `boba` does not compile
if this feature is disabled, but exists so this crate can add `no_std` support
backwards compatibly.

`bubblebabble` is [fuzzed](/fuzz/fuzz_targets) with
`boba` is [fuzzed](fuzz/fuzz_targets) with
[cargo-fuzz](https://crates.io/crates/cargo-fuzz).

## Minimum Rust Version Policy
Expand All @@ -52,9 +54,9 @@ MSRV may be bumped in minor version releases.

## License

`bubblebabble` is licensed under the [MIT License](/LICENSE) (c) Ryan Lopopolo.
`boba` is licensed under the [MIT License](LICENSE) (c) Ryan Lopopolo.

`bubblebabble` is derived from `bubble-babble-ts` @
`boba` is derived from `bubble-babble-ts` @
[v1.0.1](https://github.com/JonathanWilbur/bubble-babble-ts/tree/v1.0.1).
`bubble-babble-ts` is licensed under the
[MIT License](https://github.com/JonathanWilbur/bubble-babble-ts/blob/v1.0.1/LICENSE.txt)
Expand Down
13 changes: 7 additions & 6 deletions benches/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
#![feature(test)]

extern crate test;

mod encode {
#[bench]
fn benchmark_encode_empty(b: &mut ::test::Bencher) {
b.iter(|| bubblebabble::encode([]))
b.iter(|| boba::encode([]))
}

#[bench]
fn benchmark_encode_vector_1234567890(b: &mut ::test::Bencher) {
b.iter(|| bubblebabble::encode("1234567890"))
b.iter(|| boba::encode("1234567890"))
}

#[bench]
fn benchmark_encode_vector_pineapple(b: &mut ::test::Bencher) {
b.iter(|| bubblebabble::encode("Pineapple"))
b.iter(|| boba::encode("Pineapple"))
}
}

mod decode {
#[bench]
fn benchmark_decode_empty(b: &mut ::test::Bencher) {
b.iter(|| bubblebabble::decode("xexax"))
b.iter(|| boba::decode("xexax"))
}

#[bench]
fn benchmark_decode_vector_1234567890(b: &mut ::test::Bencher) {
b.iter(|| bubblebabble::decode("xesef-disof-gytuf-katof-movif-baxux"))
b.iter(|| boba::decode("xesef-disof-gytuf-katof-movif-baxux"))
}

#[bench]
fn benchmark_decode_vector_pineapple(b: &mut ::test::Bencher) {
b.iter(|| bubblebabble::decode("xigak-nyryk-humil-bosek-sonax"))
b.iter(|| boba::decode("xigak-nyryk-humil-bosek-sonax"))
}
}
4 changes: 2 additions & 2 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[package]
name = "bubblebabble-fuzz"
name = "boba-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
Expand All @@ -12,7 +12,7 @@ cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.3"

[dependencies.bubblebabble]
[dependencies.boba]
path = ".."

# Prevent this from interfering with workspaces
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
let _ = bubblebabble::decode(data);
let _ = boba::decode(data);
});
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
let _ = bubblebabble::encode(data);
let _ = boba::encode(data);
});
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
let encoded = bubblebabble::encode(data);
let roundtripped = bubblebabble::decode(encoded).unwrap();
let encoded = boba::encode(data);
let roundtripped = boba::decode(encoded).unwrap();
assert_eq!(roundtripped, data);
});
40 changes: 20 additions & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
//! You can encode binary data by calling [`encode`]:
//!
//! ```
//! let enc = bubblebabble::encode("Pineapple");
//! let enc = boba::encode("Pineapple");
//! assert_eq!(enc, "xigak-nyryk-humil-bosek-sonax");
//! ```
//!
//! Decoding binary data is done by calling [`decode`]:
//!
//! ```
//! # fn main() -> Result<(), bubblebabble::DecodeError> {
//! let dec = bubblebabble::decode("xexax")?;
//! # fn main() -> Result<(), boba::DecodeError> {
//! let dec = boba::decode("xexax")?;
//! assert_eq!(dec, vec![]);
//! # Ok(())
//! # }
Expand All @@ -34,8 +34,8 @@
//! will fail.
//!
//! ```
//! # use bubblebabble::DecodeError;
//! let dec = bubblebabble::decode("x🦀x");
//! # use boba::DecodeError;
//! let dec = boba::decode("x🦀x");
//! // The `DecodeError` contains the offset of the first invalid byte.
//! assert_eq!(Err(DecodeError::InvalidByte(1)), dec);
//! ```
Expand All @@ -62,7 +62,7 @@ const CONSONANTS: [u8; 16] = *b"bcdfghklmnprstvz";
const HEADER: u8 = b'x';
const TRAILER: u8 = b'x';

/// Decoding errors from [`bubblebabble::decode`](decode).
/// Decoding errors from [`boba::decode`](decode).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum DecodeError {
/// Checksum mismatch when decoding input.
Expand Down Expand Up @@ -100,9 +100,9 @@ impl fmt::Display for DecodeError {
/// # Examples
///
/// ```
/// assert_eq!(bubblebabble::encode([]), "xexax");
/// assert_eq!(bubblebabble::encode("1234567890"), "xesef-disof-gytuf-katof-movif-baxux");
/// assert_eq!(bubblebabble::encode("Pineapple"), "xigak-nyryk-humil-bosek-sonax");
/// assert_eq!(boba::encode([]), "xexax");
/// assert_eq!(boba::encode("1234567890"), "xesef-disof-gytuf-katof-movif-baxux");
/// assert_eq!(boba::encode("Pineapple"), "xigak-nyryk-humil-bosek-sonax");
/// ```
#[must_use]
pub fn encode<T: AsRef<[u8]>>(data: T) -> String {
Expand Down Expand Up @@ -151,9 +151,9 @@ pub fn encode<T: AsRef<[u8]>>(data: T) -> String {
/// # Examples
///
/// ```
/// assert_eq!(bubblebabble::decode("xexax"), Ok(vec![]));
/// assert_eq!(bubblebabble::decode("xesef-disof-gytuf-katof-movif-baxux"), Ok(b"1234567890".to_vec()));
/// assert_eq!(bubblebabble::decode("xigak-nyryk-humil-bosek-sonax"), Ok(b"Pineapple".to_vec()));
/// assert_eq!(boba::decode("xexax"), Ok(vec![]));
/// assert_eq!(boba::decode("xesef-disof-gytuf-katof-movif-baxux"), Ok(b"1234567890".to_vec()));
/// assert_eq!(boba::decode("xigak-nyryk-humil-bosek-sonax"), Ok(b"Pineapple".to_vec()));
/// ```
///
/// # Errors
Expand All @@ -168,14 +168,14 @@ pub fn encode<T: AsRef<[u8]>>(data: T) -> String {
/// - If the decoded result does not checksum properly, an error is returned.
///
/// ```
/// # use bubblebabble::DecodeError;
/// assert_eq!(bubblebabble::decode("x💎🦀x"), Err(DecodeError::InvalidByte(1)));
/// assert_eq!(bubblebabble::decode("x789x"), Err(DecodeError::InvalidByte(1)));
/// assert_eq!(bubblebabble::decode("yx"), Err(DecodeError::MalformedHeader));
/// assert_eq!(bubblebabble::decode("xy"), Err(DecodeError::MalformedTrailer));
/// assert_eq!(bubblebabble::decode(""), Err(DecodeError::Corrupted));
/// assert_eq!(bubblebabble::decode("z"), Err(DecodeError::Corrupted));
/// assert_eq!(bubblebabble::decode("xx"), Err(DecodeError::Corrupted));
/// # use boba::DecodeError;
/// assert_eq!(boba::decode("x💎🦀x"), Err(DecodeError::InvalidByte(1)));
/// assert_eq!(boba::decode("x789x"), Err(DecodeError::InvalidByte(1)));
/// assert_eq!(boba::decode("yx"), Err(DecodeError::MalformedHeader));
/// assert_eq!(boba::decode("xy"), Err(DecodeError::MalformedTrailer));
/// assert_eq!(boba::decode(""), Err(DecodeError::Corrupted));
/// assert_eq!(boba::decode("z"), Err(DecodeError::Corrupted));
/// assert_eq!(boba::decode("xx"), Err(DecodeError::Corrupted));
/// ```
pub fn decode<T: AsRef<[u8]>>(encoded: T) -> Result<Vec<u8>, DecodeError> {
let encoded = encoded.as_ref();
Expand Down

0 comments on commit 1ca96db

Please sign in to comment.