Tycho
A self describing binary format designed around the serde data model.
Getting started
To get started, you can import the latest release from crates.io
[]
= "0.0.5"
or you can use the developmental version from the public git repository
[]
= "https://github.com/SamHDev/tycho.git"
Tycho
Here is the datatypes within the Tycho format:
Unit- A value containing no data. Maps directly to()Value- A primitive, terminating type.Boolean- true or false value (bool)Unsigned8- 8-bit unsigned integer (u8)Unsigned16- 16-bit unsigned integer (u16)Unsigned32- 32-bit unsigned integer (u32)Unsigned64- 64-bit unsigned integer (u64)Unsigned128- 128-bit unsigned integer (u128)Signed8- 8-bit two compelement signed integer (i8)Signed16- 16-bit two compelement signed integer (i16)Signed32- 32-bit two compelement signed integer (i32)Signed64- 64-bit two compelement signed integer (i64)Signed128- 128-bit two compelement signed integer (i128)String- An UTF-8 string (&str)Char- A single UTF-8 character. (char)Bytes- An array of 8-bit bytes. (&[u8])Option- A Some or None value (Option<T>)Array- An untyped array of elementsStructure- A untyped string-value map (struct)Map- A typed key-value map (Map<K, V>)List- A typed array of values (Vec<T>)Variant- A variable element type with a given name. (enum)
Variants
Enums in rust, are arguably one of its best features.
Serde has four types of varaints in its data model.
Rather than implementing each, the Variant type is used.
Tycho Elements
Tycho elements can be instantiated directly rather than being serialised through serde.
use ;
// Instantiation
let string = string;
let array = array;
// Encoding
let bytes = encode;
// Decoding
let data = decode.unwrap;
// Unpacking
if let Array = data
# else
Serialisation
The main feature of tycho is the ability to serialise and deserialise using the serde framework.
# use Serialize;
# use tycho;
// Define a serilisable object
// Instantiate an structure
let person = Person ;
// Serialise
let element = to_element.unwrap;
// Serialise and Encode
let bytes = to_bytes.unwrap;
Deserialisation
# use Deserialize;
# use tycho;
# use Element;
# use TychoStruct;
// Define a deserialisable object (see above)
#
#
// Decode bytes
let bytes = /* vec![ ... ] */
# vec!;
let person: Person = from_bytes.unwrap;
// Decode element
let mut element = new;
element.insert;
element.insert;
element.insert;
let person: Person = from_element.unwrap;