b3-rs

Crates.iob3-rs
lib.rsb3-rs
version0.1.0
sourcesrc
created_at2020-07-03 11:08:28.394655
updated_at2020-07-06 02:36:29.279538
descriptionA Rust implementation of B3 (Better Binary Buffers)
homepagehttps://git.hjonk.systems/lauren/b3-rs/about
repositoryhttps://git.hjonk.systems/lauren/b3-rs
max_upload_size
id260967
size61,126
the iris system (u1f408)

documentation

README

b3-rs

A Rust implementation of B3 (Better Binary Buffers).

This library is in very early stages of development! There is no guarantee of API stability until we reach v1.0.0.

Parts of this library are heavily based on the original Python B3 implementation.

Usage

use b3_rs::{Item, ItemKey, ItemValue};

// Creating an item for a simple type
let string_item = Item::from("item value").with_key(ItemKey::from("item key"));
let integer_item = Item::from(123456u64).with_key(ItemKey::from(0u64));

// Creating an item collection
let dict_item = Item::new(
    ItemKey::NoKey,
    ItemValue::CompositeDict(
        vec![string_item, integer_item]
    ),
);

// Encoding items into the wire format
let encoded = dict_item.encode()?;

// Decoding items from the wire format
let (decoded, byte_count) = Item::decode(&encoded)?;
assert_eq!(byte_count, encoded.len());
assert_eq!(dict_item, decoded);

Caveats

Unimplemented item types

The following item types are currently unimplemented:

  • Decimal (type 10)
  • Sched (type 13)
  • Complex (type 16)

The error b3_rs::Error::UnimplementedB3TypeError will be returned when a message contains any of these types.

References

License

The code in this project is licensed under the MIT license. See the LICENSE file in the root of the repository for more information.

Commit count: 0

cargo fmt