1#![allow(async_fn_in_trait)]
2pub mod catalog;
3pub mod commit;
4pub mod generations;
5pub mod graph;
6#[cfg(feature = "arrow-ipc")]
7pub mod ipc;
8pub mod lance_storage_graph;
9pub mod lancefmt;
10pub mod metadata;
11pub mod traits;
12pub mod zarr_storage;
13pub mod zzarr;
14
15#[cfg(all(test, unix))]
16mod tests;
17
18use std::fmt;
19
20#[derive(Debug)]
25#[non_exhaustive]
26pub enum StorageError {
27 Io(String),
28 Serde(serde_json::Error),
29 Parquet(String),
30 Invalid(String),
31 Lance(String),
32 QueryError(String),
33 InvalidState(String),
36 UnsupportedFormat(String),
38 IPC(String),
41 UnsupportedFiletype(String),
43 DimensionMismatch {
46 expected: String,
47 found: String,
48 },
49 Overflow(String),
51 LockWouldBlock {
55 path: std::path::PathBuf,
56 },
57}
58
59impl fmt::Display for StorageError {
60 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
61 match self {
62 StorageError::Io(msg) => write!(f, "IO error: {}", msg),
63 StorageError::Serde(msg) => write!(f, "Serialization error: {}", msg),
64 StorageError::Parquet(msg) => write!(f, "Parquet error: {}", msg),
65 StorageError::Invalid(msg) => write!(f, "Invalid data: {}", msg),
66 StorageError::Lance(msg) => write!(f, "Lance error: {}", msg),
67 StorageError::QueryError(msg) => write!(f, "Query error: {}", msg),
68 StorageError::InvalidState(msg) => write!(f, "Invalid state: {}", msg),
69 StorageError::UnsupportedFormat(msg) => write!(f, "Unsupported format: {}", msg),
70 StorageError::IPC(msg) => write!(f, "Arrow IPC error: {}", msg),
71 StorageError::UnsupportedFiletype(msg) => write!(f, "Unsupported filetype: {}", msg),
72 StorageError::DimensionMismatch { expected, found } => {
73 write!(
74 f,
75 "Dimension mismatch: expected {}, found {}",
76 expected, found
77 )
78 }
79 StorageError::Overflow(msg) => write!(f, "Overflow error: {}", msg),
80 StorageError::LockWouldBlock { path } => {
81 write!(
82 f,
83 "Lock would block: {} is held by another holder",
84 path.display()
85 )
86 }
87 }
88 }
89}
90
91impl std::error::Error for StorageError {}
92
93pub type StorageResult<T> = Result<T, StorageError>;
94
95use std::sync::Once;
97
98static INIT: Once = Once::new();
99
100pub fn init() {
101 INIT.call_once(|| {
102 let env = env_logger::Env::default().default_filter_or("info");
104
105 let _ = env_logger::Builder::from_env(env).try_init();
107 });
108}