Message  Pack
msgpack-nil?
msgpack-nil
read-msgpack
write-msgpack
current-msgpack-ext-read-handler
current-msgpack-ext-write-handler
8.12

MessagePack🔗ℹ

Bogdan Popa <bogdan@defn.io>

This module provides an implementation of the MessagePack serialization format. Data is converted between MessagePack and Racket according to the following table:

MsgPack Type

Racket Contract

nil

msgpack-nil?

bool

boolean?

int

(integer-in (- (expt 2 63)) (sub1 (expt 2 64)))

float

real?

bin

bytes?

string

string?

array

list?

map

hash?

timestamp

date*?

When serializing integer values to MessagePack, the library chooses the shortest representation available.

procedure

(msgpack-nil? v)  boolean?

  v : any/c

value

msgpack-nil : symbol?

The value used to represent nil and its predicate.

procedure

(read-msgpack in)  any/c

  in : input-port?
Reads a MessagePack-encoded value from in. This implementation doesn’t do anything to protect against maliciously-constructed data, so care must be taken when reading data from untrusted sources.

Extensions may be handled by parameterizing current-msgpack-ext-read-handler.

procedure

(write-msgpack v [out])  void?

  v : any/c
  out : output-port? = (current-output-port)
Writes v to out as MessagePack-encoded data.

Extensions may be handled by parameterizing current-msgpack-ext-write-handler.

parameter

(current-msgpack-ext-read-handler)

  (-> (integer-in 0 127) bytes? any/c)
(current-msgpack-ext-read-handler handler)  void?
  handler : (-> (integer-in 0 127) bytes? any/c)
 = #f
Holds the procedure that is used to read application-specific data. The first argument is the type tag and the second is the encoded value.

The default implementation raises an exception when called.

parameter

(current-msgpack-ext-write-handler)

  (-> any/c (values (integer-in 0 127) bytes?))
(current-msgpack-ext-write-handler handler)  void?
  handler : (-> any/c (values (integer-in 0 127) bytes?))
 = #f
Holds the procedure that is used to write application-specific data. The argument is the value to encode and the result values are the desired type tag and the value encoded as bytes, respectively.

The default implementation raises an exception when called.