Hash invariant Binary Object Notation (HiBON)

HiBON is a streamable data format which is able to contain common binary data types. Pronounced ‘Haibon’ Description of the binary package format Package size A data package is defined as a length followed by a data byte array. The length field is the length of the byte array. Length field Data unsigned LEB128 byte array The length field is defined by a unsigned LEB128. Basic Types The HiBON binary format describe here in pseudo-BNF format....

LEB128 Integer encoding

The LEB128 https://en.wikipedia.org/wiki/LEB128 format is used store the integer values in the HiBON stream. D encoding & decoding samples Sample to encode to LEB128 in D @safe immutable(ubyte[]) encode(T)(const T v) pure if(isUnsigned!T && isIntegral!T) { ubyte[T.sizeof+2] data; alias BaseT=TypedefType!T; BaseT value=cast(BaseT)v; foreach(i, ref d; data) { d = value & 0x7f; value >>= 7; if (value == 0) { return data[0..i+1].idup; } d |= 0x80; } assert(0); } @safe immutable(ubyte[]) encode(T)(const T v) pure if(isSigned!...

JSON Interchange Format (HiBONJSON)

Converting between HiBON and JSON To secure than HiBON is hash invariant when HiBON is converted back and forth between HiBON and JSON. The JSON must flow the format described below. A HiBON object must be generated as a JSON object and a HiBON array must be generated as a JSON object. HiBON data types must be generated as a JSON array with two element where the element index 0 is HiBON type as a string and element index 1 is the contains the value....

Remote Procedure Calls (HiRPC)

HiBON Remote Procedure Call (HiRPC) HiRPC is a RPC which can including digital signatures and it is base on HiBON data format. Structure of HiRPC { $@ : 'HiPRC', $sign : <bin>, // Optional $pkey : <bin>, // Optional $msg : { id : <uint>, method : <string>, // Name of the method params : <Document>, // Optional } } The member sign is the $sign hirpc object and $pkey is the public-key which also include a $sign schema code in the genetic package....

Schema Types (HiBONRecord)  [draft]

HiBON Record ⚠️ This Document is unfinished HiBON Records Keys with prefix with # is a hash element, Only one hash element is allowed in the HiBON object. Keys with prefix with $ is a parameter. The key $@ reseved for the as a type-name all types starting with $@ is reseved for internal use.

API Examples

Usage examples in D-lang For the full hibon D api documentation see HiBON ddoc Object interface // Create an hibon auto hibon = new HiBON; // Asign something to a key hibon["hai"] = "bon"; // Create a serialized `Document` buffer hibon.toDoc; Lazy serialized documents // Where data is some ubyte[] received from the network or serialized directly from a hibon // Creates a handler for the serialized data auto doc = Document(data) // Get a string value from the buffer string decoded = doc["hai"]....