| Crates.io | b3-rs |
| lib.rs | b3-rs |
| version | 0.1.0 |
| created_at | 2020-07-03 11:08:28.394655+00 |
| updated_at | 2020-07-06 02:36:29.279538+00 |
| description | A Rust implementation of B3 (Better Binary Buffers) |
| homepage | https://git.hjonk.systems/lauren/b3-rs/about |
| repository | https://git.hjonk.systems/lauren/b3-rs |
| max_upload_size | |
| id | 260967 |
| size | 61,126 |
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.
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);
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.
The code in this project is licensed under the MIT license. See the LICENSE
file in the root of the repository for more information.