Crate jsondb

Source
Expand description

A quick-and-dirty “““embedded database””” library.

This is just a library for storing data in JSON files, but with a few added conveniences:

  • The saved data includes a schema version number, and will be automatically migrated to newer schema versions.
  • The live data is guarded by a built-in read-write lock which can be used synchronously or from a tokio async environment.
  • Data is saved to the backing JSON file, in a hopefully-atomic fashion, every time a write lock is released.

Data can be represented in pretty much any form you can convince serde to go along with, except for the following restrictions:

  • Your data type must be Debug + Send + Sync + 'static.
  • Your serialization format shouldn’t include a top-level version field of its own, as this is reserved for our schema version tracking.
  • You can’t use #[serde(deny_unknown_fields)], as this conflicts with our use of #[serde(flatten)].

Structs§

JsonDb
A JSON-backed “““database”””.

Enums§

Error
Errors that can occur while working with JsonDb.

Traits§

Schema
Schema for a JSON-backed database.
SchemaV0
Marker trait to indicate version 0 of a database schema.