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}
45
46impl fmt::Display for StorageError {
47 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
48 match self {
49 StorageError::Io(msg) => write!(f, "IO error: {}", msg),
50 StorageError::Serde(msg) => write!(f, "Serialization error: {}", msg),
51 StorageError::Parquet(msg) => write!(f, "Parquet error: {}", msg),
52 StorageError::Invalid(msg) => write!(f, "Invalid data: {}", msg),
53 StorageError::Lance(msg) => write!(f, "Lance error: {}", msg),
54 StorageError::QueryError(msg) => write!(f, "Query error: {}", msg),
55 StorageError::InvalidState(msg) => write!(f, "Invalid state: {}", msg),
56 StorageError::UnsupportedFormat(msg) => write!(f, "Unsupported format: {}", msg),
57 StorageError::UnsupportedFiletype(msg) => write!(f, "Unsupported filetype: {}", msg),
58 StorageError::DimensionMismatch { expected, found } => {
59 write!(
60 f,
61 "Dimension mismatch: expected {}, found {}",
62 expected, found
63 )
64 }
65 StorageError::Overflow(msg) => write!(f, "Overflow error: {}", msg),
66 }
67 }
68}
69
70impl std::error::Error for StorageError {}
71
72pub type StorageResult<T> = Result<T, StorageError>;
73
74use std::sync::Once;
76
77static INIT: Once = Once::new();
78
79pub fn init() {
80 INIT.call_once(|| {
81 let env = env_logger::Env::default().default_filter_or("debug");
83
84 let _ = env_logger::Builder::from_env(env).try_init();
86 });
87}