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:
i64
, f32
, f64
)The easiest way to create tuples is using the exposed tuple!
macro:
```rust
extern crate binary_tuples;
let userid = 1; let value = tuple!("users", userid, "posts");
// Returns as a byte array let bytes = value.into_bytes(); ```
Tuples can also be deserialised into a vector of tuple segments:
```rust use binary_tuples::{Tuple, segment::Segment};
let tuple = Tuple::frombytes(...) .assegments() .unwrap();
match tuple[0] { Segment::String(value) => println!("{}", value), _ => println!("Other data type") } ```
Tuples can reused as efficient prefixes for other tuples ```rust let userstuple = tuple!("users", userid, "posts");
let post1 = tuple!(userstuple, postid1); let post2 = tuple!(userstuple, postid2); ```