(lispkit serialize)
Last updated
Last updated
Library (lispkit serialize)
provides a simple API for serializing and deserializing Scheme expressions. With procedure serialize
, Scheme expressions are serialized into binary data represented as bytevectors. Such bytevectors can be deserialized back into their original value with procedure deserialize
.
Only the following types of expressions can be serialized:
Booleans
Numbers
Characters
Strings
Symbols
Bytevectors
Lists
Vectors
Hashtables
Bitsets
Date-time values
JSON values
(serializable? expr)
Returns #t
if expr is an expression which can be serialized via procedure serialize
into a bytevector. serializable?
returns #f
otherwise.
(deserializable? bvec) (deserializable? bvec start) (deserializable? bvec start end)
Returns #t
if bytevector bvec between start and end can be deserialized into a valid Scheme expression via procedure deserialize
. Otherwise, deserializable?
returns #f
.
Serializes expression expr into a binary representation returned in form of a bytevector. Only the following types of expressions can be serialized: booleans, numbers, characters, strings, symbols, bytevectors, lists, vectors, hashtables, bitsets, date-time and JSON values. If default is not provided, serialize
raises an error whenever a value that cannot be serialized is encountered. If default is provided and is serializable, then default is serialized instead of each value that is not serializable.
Deserializes a bytevector bvec between start and end into a Scheme expression. deserialize
raises an error if the bytevector cannot be deserialized successfully.
(serialize expr) (serialize expr default)
(deserialize bvec) (deserialize bvec start) (deserialize bvec start end)