preserves-nim/README.md

22 lines
1.2 KiB
Markdown
Raw Normal View History

2021-10-25 17:07:16 +00:00
# Preserves
2022-05-24 12:02:56 +00:00
Nim implementation of the [Preserves data language](https://preserves.dev/).
2021-09-08 09:11:54 +00:00
2023-04-06 01:05:42 +00:00
If you don't know why you need Preserves, see the [Syndicate library](https://git.syndicate-lang.org/ehmry/syndicate-nim).
2021-10-25 17:07:16 +00:00
## Library
2022-05-24 12:02:56 +00:00
To parse or produce Preserves one should write a [schema](https://preserves.dev/preserves-schema.html) and generate a Nim module using the [preserves_schema_nim](./src/preserves/preserves_schema_nim.nim) utility. This module will contain Nim types corresponding to schema definitions. The `toPreserve` and`fromPreserve` routines will convert Nim types to and from Preserves. The `decodePreserves`, `parsePreserves`, `encode`, and `$` routines will convert `Preserve` objects to and from binary and textual encoding.
2021-10-25 17:07:16 +00:00
2022-05-24 12:02:56 +00:00
To debug the `toPreserves` and `fromPreserves` routines compile with `-d:tracePreserves`.
2021-10-25 17:07:16 +00:00
2021-09-08 09:11:54 +00:00
## Utilities
* preserves_schema_nim
* preserves_encode
* preserves_decode
* preserves_from_json
* preserves_to_json
2021-10-25 17:07:16 +00:00
### Installation
2022-05-24 12:02:56 +00:00
`preserves_encode` is a multi-call binary that implements `preserves_encode`, `preserves_decode`, `preserves_from_json`, and `preserves_to_json`, so the appropriate symlinks should be created during packaging.