[][src]Crate b3_rs

Rust implementation of B3 (Better Binary Buffers).

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

Usage

// 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:

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

Modules

datatypes

Data type definitions.

Structs

Item

A singular item.

ItemHeader

A representation of an item's header.

Enums

Error

Error type for encode and decode operations.

ItemKey

An item key.

ItemValue

The value of an item.