No description
Find a file
Michał Zieliński fa69fd7db7
Update README.md
2021-01-05 18:01:06 +01:00
capnp fix for 32-bit systems, test improvements 2018-01-22 09:20:48 +01:00
caprpc template fix 2018-05-07 13:28:47 +02:00
examples fix for 32-bit systems, test improvements 2018-01-22 09:20:48 +01:00
fuzz add AFL fuzzing support, fix some noncritical bugs 2017-09-11 10:56:56 +02:00
tests fix for 32-bit systems, test improvements 2018-01-22 09:20:48 +01:00
util fix for 32-bit systems, test improvements 2018-01-22 09:20:48 +01:00
.gitignore nimenv support, grammar in README 2016-11-16 21:47:36 +01:00
build.sh GC improvements 2017-07-09 18:48:27 +02:00
capnp.nim support for serializing two-element tuples 2017-12-25 13:18:13 +01:00
capnp.nimble bump version to 0.0.3 2016-12-19 17:53:04 +01:00
caprpc.nim schemaless copying, RPC calculator example, other improvements 2016-12-07 09:43:10 +01:00
LICENSE first commit 2016-01-11 13:37:53 +01:00
nimenv.cfg serialization fixes, RPC codegen and improvements 2016-12-05 11:19:49 +01:00
README.md Update README.md 2021-01-05 18:01:06 +01:00
TODO.md fix capability unpack error 2017-02-11 23:12:03 +01:00

capnp.nim

Cap'n Proto bindings for Nim

WARNING: the project is not actively maintained

capnp.nim is a Nim implementation of Cap'n Proto serialization scheme and RPC protocol.

The serialization layer is production ready. The RPC layers is also fairly well tested, enough to be useful, but not the whole protocol is implemented.

The main user of this library is MetaContainer.

Installing

Use nimble to install capnp.nim:

nimble install capnp

Create symlink to canpnc binary result (capnp compiler expects capnpc-nim binary, but Nimble is unable to produce binary name that contains -):

ln -s ~/.nimble/bin/capnpc ~/.nimble/bin/capnpc-nim

Generating wrapping code

capnp.nim can generate Nim types (with some metadata) from .capnp file. The resulting objects use native Nim datatypes like seq or strings (this means that this implementation, unlike C++ one, doesn't have O(1) deserialization time).

capnp compile -onim your-protocol-file.capnp > you-output-file.nim

Using the library

import persondef, capnp
# unpack the raw serialized data
let p: Person = newUnpackerFlat(packed).unpackStruct(0, Person)
# and pack again
let packed2 = packStruct(p)

Debugging options

Define the following symbols during compilation (e.g -d:caprpcTraceMessages):

  • caprpcTraceMessages - print all messages sent by RPC system
  • caprpcTraceLifetime - print info about release messages, useful while debugging cross-machine leaks
  • caprpcPrintExceptions - print exceptions raised inside called methods (server)