1#![allow(async_fn_in_trait)]
2pub mod catalog;
3pub mod generations;
4pub mod lance_storage_graph;
5pub mod lancefmt;
6pub mod metadata;
7pub mod traits;
8
9#[cfg(test)]
10mod tests;
11
12use std::fmt;
13
14#[derive(Debug)]
19#[non_exhaustive]
20pub enum StorageError {
21 Io(String),
22 Serde(serde_json::Error),
23 Parquet(String),
24 Invalid(String),
25 Lance(String),
26 QueryError(String),
27 InvalidState(String),
30 UnsupportedFormat(String),
32 UnsupportedFiletype(String),
34 DimensionMismatch {
37 expected: String,
38 found: String,
39 },
40 Overflow(String),
42}
43
44impl fmt::Display for StorageError {
45 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
46 match self {
47 StorageError::Io(msg) => write!(f, "IO error: {}", msg),
48 StorageError::Serde(msg) => write!(f, "Serialization error: {}", msg),
49 StorageError::Parquet(msg) => write!(f, "Parquet error: {}", msg),
50 StorageError::Invalid(msg) => write!(f, "Invalid data: {}", msg),
51 StorageError::Lance(msg) => write!(f, "Lance error: {}", msg),
52 StorageError::QueryError(msg) => write!(f, "Query error: {}", msg),
53 StorageError::InvalidState(msg) => write!(f, "Invalid state: {}", msg),
54 StorageError::UnsupportedFormat(msg) => write!(f, "Unsupported format: {}", msg),
55 StorageError::UnsupportedFiletype(msg) => write!(f, "Unsupported filetype: {}", msg),
56 StorageError::DimensionMismatch { expected, found } => {
57 write!(
58 f,
59 "Dimension mismatch: expected {}, found {}",
60 expected, found
61 )
62 }
63 StorageError::Overflow(msg) => write!(f, "Overflow error: {}", msg),
64 }
65 }
66}
67
68impl std::error::Error for StorageError {}
69
70pub type StorageResult<T> = Result<T, StorageError>;
71
72use std::sync::Once;
74
75static INIT: Once = Once::new();
76
77pub fn init() {
78 INIT.call_once(|| {
79 let env = env_logger::Env::default().default_filter_or("debug");
81
82 let _ = env_logger::Builder::from_env(env).try_init();
84 });
85}