Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 43 variants Io(Error), Corruption { page_id: u64, }, WalCorruption { frame_offset: u64, }, InvalidFormat { reason: &'static str, }, InvalidArgument(&'static str), BTreeDepthExceeded { limit: usize, }, BTreeKeyTooLarge { key_len: usize, max: usize, }, BTreeValueTooLarge { value_len: usize, max: usize, }, BTreeKeyExists, BTreeScanLimitExceeded { limit: usize, }, BTreeInvariantViolated { reason: &'static str, }, DocumentTooLarge { len: usize, max: usize, }, CollectionIdMismatch { expected: u32, found: u32, }, SchemaMigrationNotImplemented { collection: &'static str, from_version: u32, to_version: u32, }, SchemaVersionFromFuture { collection: &'static str, from: u32, to: u32, }, CollectionAlreadyExists { name: String, }, IdSpaceExhausted { collection: String, }, Codec(Error), Busy { kind: LockKind, }, ReadOnly { operation: &'static str, }, CollectionNotFound { name: String, }, DocumentNotFound { collection: &'static str, id: u64, }, IndexFieldMissing { collection: String, index: String, path: String, }, IndexNotFound { collection: String, name: String, }, IndexNotUnique { collection: String, name: String, }, IndexKindMismatch { name: String, expected: IndexKind, found: IndexKind, }, IndexKeyPathsMismatch { name: String, }, UniqueConstraintViolation { collection: String, index: String, key: Vec<u8>, }, EachIndexTooLarge { collection: String, index: String, len: usize, max: usize, }, IndexFieldTypeMismatch { collection: String, index: String, path: String, expected: &'static str, found: &'static str, }, SortBufferExceeded { limit: usize, }, SortKeyEncode { source: Box<Error>, }, DistinctCountExceeded { limit: usize, }, SchemaNotRegistered { collection: &'static str, version: u32, }, SchemaDepthExceeded { depth: usize, }, SchemaTypeMismatch { expected: &'static str, found: &'static str, path: String, }, DynamicPathNotMap { path: String, }, BackupDestinationExists { path: PathBuf, }, BackupNotSupportedForMemoryPager, AttachmentAlreadyExists { namespace: String, }, AttachmentNotReadable { path: PathBuf, source: Box<Error>, }, AttachedDatabaseIsReadOnly { namespace: String, collection: String, }, CollectionNamespaceUnknown { namespace: String, },
}
Expand description

The pager-level error type.

Construct variants directly when synthesising an error; downstream callers should match exhaustively or use the #[non_exhaustive] catch-all so that future variants are not source-breaking additions.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Io(Error)

An I/O error from the platform layer (file open, read, write, flush). Wraps the underlying std::io::Error for inspection and never silently discards it (Rule 7).

§

Corruption

The on-disk image is malformed or its checksum does not match. page_id is the page where corruption was detected; the value 0 refers to the file header. The error carries no source — corruption is the direct failure mode.

Fields

§page_id: u64

Page index where the corruption was detected. 0 = header.

§

WalCorruption

A WAL frame whose CRC32C does not validate sits before the last commit marker in the current generation. Unlike a torn tail (silently discarded), mid-WAL corruption is a recovery error: replaying past it would drop or alias durable data, and recovery refuses to guess. frame_offset is the byte offset of the bad frame in the WAL file. See docs/format.md § Recovery semantics.

Fields

§frame_offset: u64

Byte offset of the corrupted frame inside the WAL sidecar.

§

InvalidFormat

The file’s magic, page-size, or major version is not what this build of the library understands. Distinct from Corruption because the file may be perfectly valid for a different reader.

Fields

§reason: &'static str

Human-readable explanation; intended for logging, not for programmatic dispatch.

§

InvalidArgument(&'static str)

Caller passed an out-of-range PageId, capacity, or similar numeric input that the type system could not statically rule out. Always indicates a caller bug.

§

BTreeDepthExceeded

A B+tree traversal exceeded its statically-bounded depth limit (MAX_BTREE_DEPTH = 32). Power-of-ten Rule 1: every recursive shape is bounded; this is the surfaced error when the bound trips, not a panic.

Fields

§limit: usize

The bound that was exceeded.

§

BTreeKeyTooLarge

A B+tree insert was given a key longer than the format spec permits (PAGE_SIZE / 4). See docs/format.md § Key and value encoding.

Fields

§key_len: usize

The offending key’s length in bytes.

§max: usize

The maximum permitted key length in bytes.

§

BTreeValueTooLarge

A B+tree insert was given a value too large to fit inline in a leaf alongside at least one slot. Overflow chains are deferred to a future minor format version.

Fields

§value_len: usize

The offending value’s length in bytes.

§max: usize

The maximum value length that still fits inline.

§

BTreeKeyExists

A B+tree insert was given a key that already exists in the tree. M4 trees do not allow duplicates; the multi-value / composite-key story arrives in M7.

§

BTreeScanLimitExceeded

A B+tree range scan exceeded the per-scan node budget (MAX_RANGE_NODES = 1_000_000). Power-of-ten Rule 2.

Fields

§limit: usize

The bound that was exceeded.

§

BTreeInvariantViolated

A B+tree invariant that debug_assert! would normally catch has tripped in a release build. Surfaced as an Error rather than a panic per power-of-ten Rules 5 + 7.

Fields

§reason: &'static str

Human-readable description of the violated invariant.

§

DocumentTooLarge

A document encode call produced a record larger than the B+tree leaf can hold inline. Overflow chains for oversize documents are deferred to a later format-minor (see docs/format.md § Document records). M5 documents must fit inline.

Fields

§len: usize

Total record length (per-doc header + postcard payload).

§max: usize

Maximum length that still fits inline in a leaf.

§

CollectionIdMismatch

A decode call observed a per-document header whose collection_id does not match the catalog row for the Document type being decoded. Indicates a programming bug (wrong type at a key) or a forensic mishap (cross-collection byte forgery) — never a transient I/O issue.

Fields

§expected: u32

The collection id the caller said this record should belong to.

§found: u32

The collection id the on-disk record actually carries.

§

SchemaMigrationNotImplemented

The on-disk record’s type_version is older than the Document::VERSION of the Rust type, and that type’s Migrate impl is the default-erroring body. Real Document types override Migrate::migrate to handle this.

Fields

§collection: &'static str

The collection whose record could not be migrated.

§from_version: u32

The stored type_version.

§to_version: u32

The reader’s Document::VERSION.

§

SchemaVersionFromFuture

The on-disk record’s type_version is newer than the reader’s Document::VERSION. The reader refuses to guess what the unknown fields mean — better a hard error than a silent loss of data.

Fields

§collection: &'static str

The collection whose record was rejected.

§from: u32

The stored type_version (larger than reader’s).

§to: u32

The reader’s Document::VERSION.

§

CollectionAlreadyExists

Catalog::insert was called for a name already present in the catalog. The user should call Catalog::update instead, or pick a different name.

Fields

§name: String

The collection name that was already registered.

§

IdSpaceExhausted

Per-collection Id allocator exhausted its u64 space, or the catalog’s per-collection-id u32 space. At 10⁹/sec the u64 case takes ~584 years; this is a defense-in-depth check (Rule 5) not a likely runtime event.

The collection field is an owned String so user-supplied &str names can be reported verbatim without leaking a 'static slot. The #[non_exhaustive] attribute on Error keeps this widening backward-compatible for downstream pattern-matchers.

Fields

§collection: String

The collection (or "<catalog>") whose id allocator was exhausted.

§

Codec(Error)

A postcard encode or decode operation failed at the codec boundary. The wrapped error carries postcard’s diagnostic; obj does not further interpret it because postcard is treated as a black-box codec (docs/format.md § Postcard pin).

§

Busy

A cross-process or in-process lock was contended for the caller-supplied timeout (Config::busy_timeout or the explicit deadline passed to FileHandle::lock_writer / FileHandle::lock_reader). Power-of-ten Rule 2: every wait has an explicit budget; exhausting it surfaces here rather than blocking the caller forever. See docs/format.md § File locking for the lock-byte layout and the protocol.

Fields

§kind: LockKind

Which lock category was contended.

§

ReadOnly

The Db was opened with Db::open_readonly and the caller invoked an operation that would mutate the database. Surfaced eagerly so callers never have to inspect the underlying lock state to know the call was illegal.

Fields

§operation: &'static str

Short label naming the call that was rejected (e.g. "insert", "transaction").

§

CollectionNotFound

A typed-API caller asked for a collection that the catalog does not have a row for. Distinct from Error::CollectionAlreadyExists (the insert-side dual); distinct from Error::Corruption (which would indicate a catalog row is malformed, not absent).

Fields

§name: String

The collection name the caller asked for.

§

DocumentNotFound

A Collection::update or Collection::delete was given an id that does not exist in the collection’s primary B-tree.

Fields

§collection: &'static str

The collection name.

§id: u64

The id that was not found.

§

IndexFieldMissing

An index extraction call (#56) was unable to resolve the configured field path against the document’s Dynamic view. The document does not carry a value at the path the index names — typically a schema-evolution gap: the type used to have the field, an older document did not, and reconciliation has not rewritten it yet.

Fields

§collection: String

The collection the index belongs to.

§index: String

The index’s name.

§path: String

The dotted path the index is keyed on.

§

IndexNotFound

Lookup of a named index against a collection’s descriptor failed: the catalog has no IndexDescriptor with that name, or the descriptor exists but is in DroppedPending status.

Fields

§collection: String

The collection the lookup was scoped to.

§name: String

The index name the caller asked for.

§

IndexNotUnique

Collection::find_unique was called on an index that is not Uniquefind_unique is only defined for unique indexes. Callers that want non-unique lookups should use Collection::lookup.

Fields

§collection: String

The collection the lookup was scoped to.

§name: String

The index name the caller asked for.

§

IndexKindMismatch

The reconciler observed a runtime crate::index::IndexSpec whose kind disagrees with the on-disk descriptor of the same name. To change an index’s kind the application must drop-then-redeclare under a different name (or rebuild from scratch); silent in-place rewrites would invalidate any extant entries.

Fields

§name: String

The index name.

§expected: IndexKind

The runtime spec’s kind.

§found: IndexKind

The on-disk descriptor’s kind.

§

IndexKeyPathsMismatch

The reconciler observed a runtime crate::index::IndexSpec whose key_paths disagree with the on-disk descriptor of the same name and kind. Like Error::IndexKindMismatch, the only safe response is for the application to drop-and- redeclare under a different name.

Fields

§name: String

The index name.

§

UniqueConstraintViolation

A Unique index extraction observed a key value that already exists on a different document in the same collection. The maintenance path surfaces this rather than silently overwriting; the WAL transaction rolls back so no partial state remains.

Fields

§collection: String

The collection the index belongs to.

§index: String

The index name.

§key: Vec<u8>

The encoded key bytes that collided.

§

EachIndexTooLarge

A single document’s Each extraction emitted more than the per-doc ceiling number of index entries — almost certainly the application supplied a runaway sequence rather than a real indexable field.

Fields

§collection: String

The collection the index belongs to.

§index: String

The index name.

§len: usize

The observed sequence length.

§max: usize

The per-doc cap.

§

IndexFieldTypeMismatch

An index extraction call (#56) resolved a field path but the value’s Dynamic shape disagrees with the index kind’s contract — e.g. an Each index whose target field is not a sequence, or a Composite field that resolved to a Map (only primitive Dynamic values are indexable).

Fields

§collection: String

The collection the index belongs to.

§index: String

The index’s name.

§path: String

The dotted path the index is keyed on.

§expected: &'static str

The expected Dynamic shape (e.g. "Seq" for Each).

§found: &'static str

The shape the document actually carries at the path.

§

SortBufferExceeded

An M8 query’s sort_by extension collected more than its sort_buffer_limit (default 100 000) candidate documents before the sort+truncate step could narrow them down. Power-of-ten Rule 3: the in-memory sort is bounded; the user should add a .filter / .index_range / .limit that bounds the survivors, or raise the limit explicitly via .sort_buffer_limit(N) if the workload genuinely needs it.

M8 sorts are designed for “screen-of-results” workloads, not “sort a million rows” workloads; a disk-spill sort is the post-M8 follow-up if this turns out to be too restrictive.

Fields

§limit: usize

The bound that was exceeded.

§

SortKeyEncode

An M8 query’s sort_by extractor produced a Dynamic whose obj_core::index::encode_field representation could not be computed (e.g. a Dynamic::String carrying an embedded NUL byte, which the order-preserving encoder rejects). Power-of- ten Rule 7: the underlying error is propagated rather than silently collapsed into an empty key. Callers who want to control the encoding themselves should use Query::sort_by_bytes, which never touches encode_field.

Fields

§source: Box<Error>

The underlying encoder failure. Boxed to keep Error (which contains this variant) Sized.

§

DistinctCountExceeded

Collection::count_distinct_ids_in_range (M8 follow-up #72) observed more than the caller-configurable per-call cap of distinct Ids while walking the index B-tree. Power-of-ten Rule 3: the in-memory HashSet<Id> is bounded; the user should narrow the range via .index_range(...) so fewer distinct docs fall inside the window. The fast path on the query layer dispatches to this routine ONLY for Each-kind indexes — other kinds count entries via the cheaper count_index_range path that has no distinct-tracking cost.

Fields

§limit: usize

The bound that was exceeded.

§

SchemaNotRegistered

codec::decode saw an on-disk record whose type_version is older than the reader’s Document::VERSION, but the reader’s Document::historical_schemas() has no entry for that version (M10 issue #82 introduces the registry; M10 issue #83 wires this error). The codec refuses to invent a Dynamic view — silent fallback hides schema-evolution bugs.

Fields

§collection: &'static str

The collection whose record could not be migrated.

§version: u32

The stored type_version for which no schema was found.

§

SchemaDepthExceeded

The postcard byte-stream walker driven by Dynamic::from_postcard_bytes exceeded the depth bound MAX_SCHEMA_DEPTH. Power-of-ten Rule 1: the walker uses an explicit stack, but the stack depth is itself bounded to avoid a pathological schema triggering unbounded growth.

Fields

§depth: usize

The bound that was exceeded.

§

SchemaTypeMismatch

The postcard byte-stream walker observed a payload that disagrees with the supplied schema in a way the schema itself cannot recover from (e.g. a Bool slot carrying a byte other than 0 / 1, a String slot whose bytes are not UTF-8, or a Seq length that overflows the input). M10 issue #41.

Fields

§expected: &'static str

The schema-side variant the walker was decoding when the mismatch surfaced.

§found: &'static str

The shape the bytes actually carried (e.g. "non-utf8", "truncated", "non-bool-byte").

§path: String

Dotted path naming the schema slot where the mismatch surfaced — useful for forensic logging on a real migration failure.

§

DynamicPathNotMap

Dynamic::remove (M10 issue #85) was called on a Dynamic whose root value (or any intermediate path segment) is not a Map. Map-only by construction — callers needing scalar removal should replace the value outright via Dynamic::set.

Fields

§path: String

The dotted path that resolved to a non-Map value.

§

BackupDestinationExists

Db::backup_to (M11 #92) was called with a destination path that already exists. The backup never overwrites existing files — the operator must remove the destination explicitly or pick a fresh path.

Fields

§path: PathBuf

The destination path the call refused to write.

§

BackupNotSupportedForMemoryPager

Db::backup_to (M11 #92) was called on an in-memory database. Memory pagers have no file backend; serialising the in-memory state to a fresh .obj file is deferred to a future minor.

§

AttachmentAlreadyExists

Db::attach (M11 #93) was called with a namespace already registered on the calling Db. Detach the existing attachment first or pick a different namespace.

Fields

§namespace: String

The namespace the caller tried to register.

§

AttachmentNotReadable

Db::attach (M11 #93) was unable to open the attached file. The wrapped error carries the underlying cause (typically Error::Io or Error::Corruption).

Fields

§path: PathBuf

The path the caller tried to attach.

§source: Box<Error>

Underlying open failure.

§

AttachedDatabaseIsReadOnly

Db::insert / Db::update / Db::delete / Db::upsert (and the WriteTxn::collection<T>() equivalents) refused to mutate a collection whose name resolves to an attached database. Attached databases are read-only through the calling Db (M11 #93).

Fields

§namespace: String

Namespace prefix that resolved to an attached db.

§collection: String

The unqualified collection name within the attached db.

§

CollectionNamespaceUnknown

A namespaced collection name was opened against a calling Db that has no attachment registered under the namespace.

Fields

§namespace: String

The namespace prefix that did not resolve.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<ErrorKind> for Error

Source§

fn from(kind: ErrorKind) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl !UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V