You are looking at historical revision 39759 of this page. It may differ significantly from its current revision.

msgpack

An implementation of MessagePack for CHICKEN scheme v5.

Forked from msgpack-scheme and partially rewritten (ported to CHICKEN 5 and built-in byte blob API). I kept the original license and most of the original API. However, the byte-blob have been replaced with Chicken 5 native blob. I removed the dependency on bind egg and the need for C++ code using built-ins features of C5.

Authors

Hugo Arregui: Original author of the egg.

Théo Cavignac: ported the egg to Chicken 5

Repository

Find the code at github.com.

Requirements

This package requires the following eggs:

Installation

Through Chicken egg repository: Run chicken-install -s msgpack anywhere.

From source:

  1. Install the required eggs listed above.
  2. Clone this repository.
  3. Run chicken-install -s in the root of this repository.

API Specification

Primitive pack-family procedures:

[procedure] (pack-uint port value)
[procedure] (pack-sint port value)

pack integer, will produce an error if the input does not respect the expected signedness

[procedure] (pack-float port FLONUM)

pack 32b floats, support both exact and inexact but convert to flonum (inexact) anyway

[procedure] (pack-double port FLONUM)

pack 64b floats, support both exact and inexact but convert to flonum (inexact) anyway

[procedure] (pack-bin port BLOB)

pack chicken.blob byte blob

[procedure] (pack-str port STRING)

pack string

[procedure] (pack-array port VECTOR)

pack scheme vectors or lists

[procedure] (pack-map port HASH-TABLE)

pack srfi-69 hash-table

[procedure] (pack-ext port EXT)

pack extension record (see below)

Automatic procedures:

[procedure] (pack port value)

Will infer the right packer to use and write the msgpack result to port

[procedure] (pack/blob value)

Will inter the right packer and return the message as a byte blob

These procedures will call primitive type packers, with the following rules:

The /blob version return a blob of packed data, the others directly write it to the port.

Unpack procedures: <procedure>(unpack port [mapper])</procedure> Read msgpack data from port and return the unpacked data.

[procedure] (unpack/blob blob [mapper])

Treat the blob as a msgpack data and return the unpacked data.

The optional mapper argument is applied to the output before returning. The /blob version unpack the content of blob instead of reading from a port.

Extension

Extension is a record defined as:

(define-record extension type data)

Use-case example:

(make-extension 10 (string->byte-blob "hi"))

License

Distributed under the New BSD License.

History