Home

Awesome

bingo — Binary serialization framework for Nim

About

This package provides the binTo, loadBin procs which deserialize the specified type from a Stream. The storeBin procs are used to write the binary representation of a location into a Stream. Low level initFromBin and storeBin procs can be overloaded, in order to support arbitary container types, i.e. marshal_smartptrs.nim.

Usage

import std/streams, bingo

type
  Foo = ref object
    value: int
    next: Foo

let d = Foo(value: 1, next: Foo(value: 2, next: nil))
let s = newStringStream()
# Make a roundtrip
s.storeBin(d) # writes binary from a location
s.setPosition(0)
let a = s.binTo(Foo) # reads binary and transform to a type
# Alternatively load directly into a location
s.setPosition(0)
var b: Foo
s.loadBin(b)

Features

Limitations