Skip to main content

Module database

Module database 

Source

Structs§

BackupOptions
BackupResult
ConvertOptions
ConvertResult
Database
A directory of tables: the JSONL logs, their index snapshots, the metadata catalog (hayson.json) describing them, and one writer lock (lock::DirLock, ADR-hjxp/0006 — one writer per database directory).
Layout
Absolute paths of everything a database keeps on disk, by role — the port of the TS Layout, narrowed to the roles this engine actually writes (format 2 keeps no per-table schema files, and its write queue stages in memory rather than in a pending/ directory).
LayoutMigrationOptions
Which arrangement to move a database into, and under what name to leave its metadata document.
LayoutMigrationResult
What migrate_layout moved, or would move under dry_run.
LayoutMove
One rename the move makes, as it will be applied.
LayoutOptions
The layout/metadataFile/manifest triple of OpenOptions, exactly as a caller passed it — unresolved, because which of the two file names wins (and whether they even agree) is decided by LayoutOptions::metadata_file, and the kind by [resolve_kind].
OpenOptions
How Database::open acquires the writer lock and whether it opens for writing at all.
PackInclude
A nested database to pack along with the main one.
PackLimits
What a pack may hold and what an unpack accepts. The same limits guard both directions, so a pack this engine writes is one it reads back.
PackOptions
PackResult
PackedDatabase
What one packed database contributed.
Problem
One finding of verify. code is a stable kebab-case identifier callers can match on; message is for people.
RestoreOptions
RestoreResult
UnpackOptions
VerifyOptions
VerifyReport

Enums§

DatabaseError
FollowOption
Whether the tables of this database catch up with foreign writes on their own — the port of the TS OpenOptions.follow, which takes false, true or { intervalMs }.
LayoutKind
How a database directory is arranged on disk — the port of the TS LayoutKind.
LockMode
Whether Database::open takes the writer lock at all, and on what terms when it does.
RestoreOutcome
Severity
How much a finding matters to someone about to open the directory.

Constants§

BACKUP_MANIFEST
The manifest a backup carries next to the files it copied.
DEFAULT_METADATA_FILE
Name of the metadata document a database keeps in its root when open() names none — the port of the TS DEFAULT_MANIFEST_FILE (packages/hayson/src/database/layout.ts).

Functions§

backup_database
Copies a database directory into dest: the files the database accounts for (see [owned_files]) plus a hayson-backup.json manifest listing them with their sizes.
convert_encryption
Seals a plain database, unseals an encrypted one, or re-seals one under other keys, in place and recoverably (the stage, verify, swap and roll-back of super::restore_database).
migrate_layout
Moves a database between the flat and nested on-disk arrangements.
pack_database
Packs a database directory into one zip archive at dest: the files the database accounts for, stored without compression, plus the hayson-backup.json manifest and the caller’s extra entries. Databases named in include travel in the same archive under their folder, each with a <folder>/hayson-backup.json of its own; the main manifest lists their folders.
read_pack_entry
Reads one entry of a pack — the caller’s own manifest, say — after the same checks an unpack makes. None when the archive has no entry of that name.
restore_database
Restores a backup made by backup_database into dir, replacing the database that is there.
unpack_database
Unpacks an archive made by pack_database into dir, replacing the database that is there (and the nested ones the archive carries), with the recoverable procedure of super::restore_database (stage, verify, swap, roll back).
verify
Checks a database directory without taking its lock or changing a byte, and reports what is wrong with it instead of failing on it: every damaged, missing or unreadable file becomes a Problem, never an Err and never a panic.