1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Error and Result definitions for TapirusDB
use thiserror::Error;
/// TapirusDB Result type alias
pub type Result<T> = std::result::Result<T, Error>;
/// Enumeration of all possible TapirusDB error variants
#[derive(Error, Debug)]
pub enum Error {
/// Input/Output failure on disk file
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
/// Invalid database file magic header
#[error("Invalid magic bytes: file is not a valid TapirusDB database")]
InvalidMagic,
/// File format requires a newer/different engine.
#[error("Unsupported TapirusDB file format version {0}")]
UnsupportedFormat(u16),
/// Page size is invalid (must be power of 2 between 512 and 65536)
#[error("Invalid page size {0}: must be power of 2 between 512 and 65536")]
InvalidPageSize(u16),
/// Page corrupted or checksum mismatch
#[error("Page {0} corrupted: checksum mismatch (expected {1:#x}, found {2:#x})")]
PageCorrupted(u32, u32, u32),
/// Page not found
#[error("Page {0} not found in database file")]
PageNotFound(u32),
/// SQL syntax error
#[error("SQL syntax error: {0}")]
SqlSyntax(String),
/// Table already exists
#[error("Table '{0}' already exists")]
TableExists(String),
/// Table does not exist
#[error("Table '{0}' does not exist")]
TableNotFound(String),
/// Column does not exist
#[error("Column '{0}' does not exist")]
ColumnNotFound(String),
/// Vector dimension mismatch
#[error("Vector dimension mismatch: expected {0} dimensions, got {1}")]
DimensionMismatch(usize, usize),
/// Decryption failed due to invalid key or corrupted MAC
#[error("Decryption failed for page {0}: invalid encryption key or corrupted ciphertext")]
DecryptionFailed(u32),
/// Database is encrypted but no key was provided
#[error("Database is encrypted: encryption key required to open")]
EncryptedDatabase,
/// Transaction error (e.g. no active transaction to commit or rollback)
#[error("Transaction error: {0}")]
TransactionError(String),
/// General corruption
#[error("Database corrupted: {0}")]
Corrupted(String),
/// Constraint violation (e.g. unique constraint or duplicate primary key)
#[error("Constraint violation: {0}")]
ConstraintViolation(String),
/// Database is busy or locked by another process
#[error("Database busy: {0}")]
Busy(String),
/// Serialization or deserialization error
#[error("Serialization error: {0}")]
Serialization(String),
/// Tap decision engine or internal cognitive error
#[error("Tap decision error: {0}")]
DecisionError(String),
/// Access rejected by an enforced owner/namespace boundary
#[error("Permission denied: {0}")]
PermissionDenied(String),
/// Internal error
#[error("Internal error: {0}")]
Internal(String),
}