1#![allow(async_fn_in_trait)]
2pub mod catalog;
3pub mod commit;
4pub mod generations;
5pub mod graph;
6pub mod lance_storage_graph;
7pub mod lancefmt;
8pub mod metadata;
9pub mod traits;
10
11#[cfg(test)]
12mod tests;
13
14use std::fmt;
15
16#[derive(Debug)]
21#[non_exhaustive]
22pub enum StorageError {
23 Io(String),
24 Serde(serde_json::Error),
25 Parquet(String),
26 Invalid(String),
27 Lance(String),
28 QueryError(String),
29 InvalidState(String),
32 UnsupportedFormat(String),
34 UnsupportedFiletype(String),
36 DimensionMismatch {
39 expected: String,
40 found: String,
41 },
42 Overflow(String),
44 LockWouldBlock {
48 path: std::path::PathBuf,
49 },
50}
51
52impl fmt::Display for StorageError {
53 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54 match self {
55 StorageError::Io(msg) => write!(f, "IO error: {}", msg),
56 StorageError::Serde(msg) => write!(f, "Serialization error: {}", msg),
57 StorageError::Parquet(msg) => write!(f, "Parquet error: {}", msg),
58 StorageError::Invalid(msg) => write!(f, "Invalid data: {}", msg),
59 StorageError::Lance(msg) => write!(f, "Lance error: {}", msg),
60 StorageError::QueryError(msg) => write!(f, "Query error: {}", msg),
61 StorageError::InvalidState(msg) => write!(f, "Invalid state: {}", msg),
62 StorageError::UnsupportedFormat(msg) => write!(f, "Unsupported format: {}", msg),
63 StorageError::UnsupportedFiletype(msg) => write!(f, "Unsupported filetype: {}", msg),
64 StorageError::DimensionMismatch { expected, found } => {
65 write!(
66 f,
67 "Dimension mismatch: expected {}, found {}",
68 expected, found
69 )
70 }
71 StorageError::Overflow(msg) => write!(f, "Overflow error: {}", msg),
72 StorageError::LockWouldBlock { path } => {
73 write!(f, "Lock would block: {} is held by another holder", path.display())
74 }
75 }
76 }
77}
78
79impl std::error::Error for StorageError {}
80
81pub type StorageResult<T> = Result<T, StorageError>;
82
83use std::sync::Once;
85
86static INIT: Once = Once::new();
87
88pub fn init() {
89 INIT.call_once(|| {
90 let env = env_logger::Env::default().default_filter_or("debug");
92
93 let _ = env_logger::Builder::from_env(env).try_init();
95 });
96}