Skip to content

disruptek/frosty

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

frosty

Test Matrix GitHub release (latest by date) Minimum supported Nim version License buy me a coffee Matrix

Serialize native Nim types to strings, streams, or sockets.

Usage

There are two operations: freeze and thaw.

freeze[T](output: Socket or Stream or var string; input: T)

import frosty

var
  data = someArbitraryDataFactory()
  handle = openFileStream("somefile", fmWrite)
# write serialized data into the file handle
freeze(handle, data)
close handle

thaw[T](input: Socket or Stream or string; output: var T)

import frosty

var
  data: SomeArbitraryType
  handle = openFileStream("somefile", fmRead)
# read deserialized data from the file handle
thaw(handle, data)
close handle

freeze[T](input: T): string

thaw[T](input: Socket or Stream or string): T

import frosty

# adhoc serialization and deserialization
var brrr = freeze("my data")
assert thaw[string](brrr) == "my data"

Performance

Frosty can handle cyclic data structures.

Benchmark vs. Flatty

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.

benchmarks

Installation

$ nimph clone disruptek/frosty

or if you're still using Nimble like it's 2012,

$ nimble install https://github.com/disruptek/frosty

Documentation

The documentation employs Nim's runnableExamples feature to ensure that usage examples are guaranteed to be accurate. The documentation is rebuilt during the CI process and hosted on GitHub.

License

MIT

About

serialize native Nim types to strings, streams, sockets, whatever ⛄

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages