# LispKit Serialize

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) [procedure]

Returns `#t` if expr is an expression which can be serialized via procedure `serialize` into a bytevector. `serializable?` returns `#f` otherwise.

(deserializable? bvec) [procedure]
(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`.

(serialize expr) [procedure]
(serialize expr default)

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.

(deserialize bvec) [procedure]
(deserialize bvec start)
(deserialize bvec start end)

Deserializes a bytevector bvec between start and end into a Scheme expression. `deserialize` raises an error if the bytevector cannot be deserialized successfully.