Serialize native Nim types to strings, streams, or sockets.
There are two operations: freeze
and thaw
.
import frosty
var
data = someArbitraryDataFactory()
handle = openFileStream("somefile", fmWrite)
# write serialized data into the file handle
freeze(handle, data)
close handle
import frosty
var
data: SomeArbitraryType
handle = openFileStream("somefile", fmRead)
# read deserialized data from the file handle
thaw(handle, data)
close handle
import frosty
# adhoc serialization and deserialization
var brrr = freeze("my data")
assert thaw[string](brrr) == "my data"
Frosty can handle cyclic data structures.
The source to the following benchmark is found in the tests directory.
The benchmark compares frosty to https://github.com/treeform/flatty for a few static datatypes -- flatty does not work with cast objects yet.
$ nimph clone disruptek/frosty
or if you're still using Nimble like it's 2012,
$ nimble install https://github.com/disruptek/frosty
MIT