binary_tuples 0.1.1

Ordered binary tuple implementation for rust based upon and compatible with FoundationDB tuples
Documentation
  • Coverage
  • 53.85%
    14 out of 26 items documented3 out of 14 items with examples
  • Size
  • Source code size: 38.6 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.91 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Myrannas/binary-tuples
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Myrannas

Binary Tuples

This is a small library for working with ordered binary tuples - and is designed to be compatible with the tuples implementation bundled with FoundationDB client libraries.

This library allows use of the following data types:

  • Strings
  • Binary arrays
  • Numbers (i64, f32, f64)
  • Boolean values
  • UUIDs
  • Nested tuples (read supported - no api support for creation yet)

API

The easiest way to create tuples is using the exposed tuple! macro:

#[macro_use]
extern crate binary_tuples;

let user_id = 1;
let value = tuple!("users", user_id, "posts");

// Returns as a byte array
let bytes = value.into_bytes(); 

Tuples can also be deserialised into a vector of tuple segments:

use binary_tuples::{Tuple, segment::Segment};

let tuple = Tuple::from_bytes(...)
    .as_segments()
    .unwrap();

match tuple[0] {
    Segment::String(value) => println!("{}", value),
    _ => println!("Other data type") 
}

Tuples can reused as efficient prefixes for other tuples

let users_tuple = tuple!("users", user_id, "posts");

let post_1 = tuple!(users_tuple, post_id_1);
let post_2 = tuple!(users_tuple, post_id_2);