You can edit almost every page by Creating an account. Otherwise, see the FAQ.

Binn (serialization format)

From EverybodyWiki Bios & Wiki


Binn
Repositorygithub.com/liteserver/binn
Engine
    TypeData interchange
    LicenseApache 2.0

    Search Binn (serialization format) on Amazon.

    Binn is a computer data serialization format used mainly for application data transfer. It stores primitive data types and data structures in a binary form.[1]

    Performance[edit]

    The Binn format is designed to be compact and fast on readings. The elements are stored with their sizes to increase the read performance. The strings are null terminated so when read the library returns a pointer to them inside the buffer, avoiding memory allocation and data copying, an operation known as zero-copy.

    Data types[edit]

    Primitive data types:

    • null
    • boolean (true and false)
    • integer (up to 64 bits signed or unsigned)
    • floating point numbers (IEEE single/double precision)
    • string
    • blob (binary data)
    • User defined

    Containers:

    Format[edit]

    Binn structures consist of a list of elements. Each element has a type that can be followed by the size, count of internal items, and the data itself:

    boolean, null:
    [type]
    
    int, float (storage: byte, word, dword or qword):
    [type][data]
    
    string, blob:
    [type][size][data]
    
    list, object, map:
    [type][size][count][data]
    

    Example encoding[edit]

    A JSON data such as {"hello":"world"} is serialized in binn with the same size:

      \xE2                               // type = object (container)
      \x11                               // container total size
      \x01                               // items in the container (key/value pairs in this case)
      \x05hello                          // field name
      \xA0                               // type = string
      \x05world\x00                      // field value (null terminated)
    

    Example code[edit]

    Writing to an object in C:

    // create a new object
    binn * obj = binn_object();
    
    // add values to it
    binn_object_set_int32(obj, "id", 123);
    binn_object_set_str(obj, "name", "John");
    binn_object_set_double(obj, "total", 2.55);
    
    // send over the network or save to a file...
    send(sock, binn_ptr(obj), binn_size(obj));
    
    // release the buffer
    binn_free(obj);
    

    Reading from that object:

    int id = binn_object_int32(obj, "id");
    char * name = binn_object_str(obj, "name");
    double total = binn_object_double(obj, "total");
    

    See also[edit]

    Usages[edit]

    • LiteReplica, SQLite replication and point-in-time recovery tool.
    • EJDB2, Embeddable JSON Database engine C library.
    • GameAP, Game servers management panel.

    References[edit]

    External links[edit]


    This article "Binn (serialization format)" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Binn (serialization format). Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.