rustt 0.1.1

A wire-protocol for efficiently transfering self-describing data implemented in rust.
docs.rs failed to build rustt-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: rustt-0.1.2

RusTT

TT is a format used to serialize/deserialize data efficiently and fast. TT can be used to transmit data between processes or over the network. TT is designed to not transmit any unneccecary data and keep data sizes small but still easily readable to the machine. The TT data is structured like a key-value format, where keys can be any integer, String or Byte sequence. A value can be that or a Sequence or a Map.

At the moment only TTv3 is supported, so all encoding/decoding will be done using that. When another version is supported the enum [Version] will be used to specify the (de)serialization version.

untyped TT Values

In cases where you cannot define a static structure, there are [ttv3::Key] and [ttv3::Value]. These enums define alll possible values for a key and value.

Since TT can have floats as keys, they will be represented by [ttv3::serde::TtF32] or [ttv3::serde::TtF64], wich is a wrapper around u32 and u64 to be able to use it in a [ttv3::Value::Map]. This is not how rust usualy works and should only be used within [ttv3::Value]

# use serde_json::{Number, Map};
#
# #[allow(dead_code)]
enum Key {
String(String),
Bytes(Vec<u8>),
I8(i8),
I16(i16),
I32(i32),
I64(i64),
U8(u8),
U16(u16),
U32(u32),
U64(u64),
Bool(bool),
F32(rustt::ttv3::TtF32),
F64(rustt::ttv3::TtF64),
}
# use rustt::ttv3::{Key};
#
# #[allow(dead_code)]
enum Value {
String(String),
Bytes(Vec<u8>),
I8(i8),
I16(i16),
I32(i32),
I64(i64),
U8(u8),
U16(u16),
U32(u32),
U64(u64),
Bool(bool),
F32(rustt::ttv3::TtF32),
F64(rustt::ttv3::TtF64),
Map(std::collections::HashMap<Key, Value>),
Vec(Vec<Value>),
}

Parsing TT as strongly types data

Serde provides macro's for serializing and deserializing data structures. Rust TT is able to use these macros to do all the same things serde_json and the like can do too. For performance reasons it you should use serde_bytes for Vec<u8> and [u8]. If you do not do this other applications will read this as an array of bytes, and not as a Byte Sequence. the distinction being, in TT a byte sequence is encoded just like a string while a sequence of bytes is encoded like any other array.

Versions

TT comes in diverent versions. This crate only supports ttv3 as it is the most recent one. Any upcomming tt versions will be supported, this is the reason there is a diferent module for ttv3 specific code. [ttv3::Key], [ttv3::Value] and [ttv3::Error] are all specific to ttv3 (except maybe [ttv3::Error]) so to keep this crate backwards comptible those are in a diferent submodule.