turso_assert!() { /* proc-macro */ }Expand description
Drop-in replacement for [assert!] that additionally reports to the
Antithesis SDK when compiled with
--features antithesis.
Maps to antithesis_sdk::assert_always_or_unreachable! — the condition must be
true every time this line is reached, but it is OK if the line is never reached.
§Behavior
- Without
antithesisfeature: behaves exactly like [assert!] (panics on failure). - With
antithesisfeature: reports the property to Antithesis viaassert_always_or_unreachable!. On failure, prints the error to stderr and callsstd::process::exit(0)instead of panicking. The clean exit lets Antithesis properly process the property violation. The normalassert!is skipped in this path.
§Parameters
condition— boolean expression to check."message"(optional) — human-readable description. Auto-generated from the condition expression if omitted.{ "key": value, ... }(optional) — structured details forwarded to Antithesis as JSON and included in the panic/exit message.
§Usage
ⓘ
turso_assert!(condition);
turso_assert!(condition, "message");
turso_assert!(condition, "message", { "key": value });§Examples
ⓘ
// Simple condition (auto-generates message from expression)
turso_assert_less_than_or_equal!(value, PageSize::MAX as usize);
// With explicit message
turso_assert_greater_than!(page_idx, 0, "page index must be positive");
// With structured details for Antithesis
turso_assert_greater_than_or_equal!(
available_space, required_space,
"not enough space on page",
{ "available": available_space, "required": required_space }
);§When to use
Use turso_assert! anywhere you would use assert!. It is the default choice for
invariants that must always hold. Prefer turso_debug_assert! for expensive checks
that should only run in debug builds.