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