oxigdal_db_connectors/lib.rs
1//! Database connectors for OxiGDAL.
2//!
3//! This crate provides connectors for various database systems with spatial data support:
4//! - MySQL/MariaDB with spatial extensions
5//! - SQLite/SpatiaLite for embedded spatial databases
6//! - MongoDB with native GeoJSON support
7//! - ClickHouse for massive-scale spatial analytics
8//! - TimescaleDB for time-series geospatial data
9//! - Cassandra/ScyllaDB for distributed spatial data storage
10//!
11//! # Examples
12//!
13//! ## MySQL
14//!
15//! ```no_run
16//! use oxigdal_db_connectors::mysql::{MySqlConfig, MySqlConnector};
17//!
18//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
19//! let config = MySqlConfig::default();
20//! let connector = MySqlConnector::new(config)?;
21//! # Ok(())
22//! # }
23//! ```
24//!
25//! ## MongoDB
26//!
27//! ```no_run
28//! use oxigdal_db_connectors::mongodb::{MongoDbConfig, MongoDbConnector};
29//!
30//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
31//! let config = MongoDbConfig::default();
32//! let connector = MongoDbConnector::new(config).await?;
33//! # Ok(())
34//! # }
35//! ```
36
37#![warn(missing_docs)]
38#![deny(unsafe_code)]
39
40#[cfg(feature = "cassandra")]
41pub mod cassandra;
42#[cfg(feature = "clickhouse")]
43pub mod clickhouse;
44pub mod connection;
45pub mod error;
46#[cfg(feature = "mongodb")]
47pub mod mongodb;
48#[cfg(feature = "mysql")]
49pub mod mysql;
50#[cfg(feature = "sqlite")]
51pub mod sqlite;
52#[cfg(feature = "postgres")]
53pub mod timescale;
54
55// Re-export common types
56pub use error::{Error, Result};
57
58/// Database connector trait (for future unified interface).
59#[async_trait::async_trait]
60pub trait DatabaseConnector: Send + Sync {
61 /// Check if the connection is healthy.
62 async fn health_check(&self) -> Result<bool>;
63
64 /// Get database version.
65 async fn version(&self) -> Result<String>;
66
67 /// List all tables/collections.
68 async fn list_tables(&self) -> Result<Vec<String>>;
69}
70
71#[cfg(test)]
72mod tests {
73 use super::*;
74
75 #[test]
76 fn test_error_types() {
77 let err = Error::Connection("test".to_string());
78 assert!(err.to_string().contains("Connection"));
79 }
80}