guard

Write-time guard statements for batch_atomic that fail a whole batch, a retry loop for lost races, and a daily limit table.

Built and tested in the harness, and not in the public repository yet. The install line and the source link appear here when it is.

What it is

guard.

Write-time invariants for the Database port. The port offers batch_atomic with no interactive transactions and no row counts, so an invariant is enforced by failing the statement, not by a write that quietly does nothing. guard::assert_statement inserts a probe whose NOT NULL column is the condition; a false or unknown condition aborts the batch. run_batch_with_retry resubmits a batch that lost a unique-violation race, and a NOT NULL refusal is never retried. A daily-limit statement and an outbox table pair with the guards. The SQL is the portable SQLite dialect and runs on D1, rusqlite and Postgres.

From the crate’s own README.

Ports

Database

History

Changelog.

Not released yet. Its changelog starts with its first release.

One of 95 crates in the harness, all of them MIT.