nirv_engine/
lib.rs

1//! # NIRV Engine
2//!
3//! A universal data virtualization and compute orchestration engine that provides
4//! a unified interface to query and manipulate data across multiple sources including
5//! databases, APIs, and file systems.
6//!
7//! ## Features
8//!
9//! - **Multi-Source Connectors**: SQL Server, PostgreSQL, REST APIs, File Systems
10//! - **Protocol Adapters**: TDS, PostgreSQL Wire Protocol, HTTP/REST
11//! - **Query Engine**: Parsing, planning, and distributed execution
12//! - **Schema Introspection**: Automatic schema discovery and metadata management
13//! - **Connection Pooling**: Efficient resource management
14//! - **Async/Await**: Full async support with Tokio runtime
15//!
16//! ## Quick Start
17//!
18//! ```rust
19//! use nirv_engine::connectors::{SqlServerConnector, Connector, ConnectorInitConfig};
20//! use nirv_engine::protocol::{SqlServerProtocol, ProtocolAdapter};
21//!
22//! #[tokio::main]
23//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
24//!     // Create and configure a SQL Server connector
25//!     let mut connector = SqlServerConnector::new();
26//!     
27//!     let config = ConnectorInitConfig::new()
28//!         .with_param("server", "localhost")
29//!         .with_param("database", "mydb")
30//!         .with_param("username", "user")
31//!         .with_param("password", "password");
32//!     
33//!     // Connect to the database
34//!     connector.connect(config).await?;
35//!     
36//!     println!("Connected! Connector type: {:?}", connector.get_connector_type());
37//!     Ok(())
38//! }
39//! ```
40//!
41//! ## Architecture
42//!
43//! NIRV Engine follows a modular architecture:
44//!
45//! - [`engine`] - Query parsing, planning, and execution
46//! - [`connectors`] - Data source abstractions and implementations
47//! - [`protocol`] - Wire-level communication protocol adapters
48//! - [`utils`] - Common types, error handling, and utilities
49//! - [`cli`] - Command-line interface components
50//!
51//! ## SQL Server Support
52//!
53//! NIRV Engine provides comprehensive SQL Server support through:
54//!
55//! ### TDS Protocol Implementation
56//! - TDS 7.4 protocol support
57//! - Authentication with SQL Server credentials
58//! - Query execution with proper result formatting
59//! - Error handling with SQL Server error codes
60//!
61//! ### Connector Features
62//! - Connection management with connection pooling
63//! - Query building with SQL Server-specific syntax
64//! - Schema introspection via INFORMATION_SCHEMA
65//! - Transaction support for ACID compliance
66//!
67//! ```rust
68//! use nirv_engine::protocol::{SqlServerProtocol, Connection, Credentials, ProtocolType};
69//! use tokio::net::TcpStream;
70//!
71//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
72//! // Create protocol adapter
73//! let protocol = SqlServerProtocol::new();
74//!
75//! // Simulate authentication
76//! let credentials = Credentials::new("sa".to_string(), "master".to_string())
77//!     .with_password("password".to_string());
78//!
79//! # let stream = TcpStream::connect("127.0.0.1:1433").await?;
80//! let mut connection = Connection::new(stream, ProtocolType::SqlServer);
81//! protocol.authenticate(&mut connection, credentials).await?;
82//! # Ok(())
83//! # }
84//! ```
85//!
86//! ## REST API Integration
87//!
88//! ```rust
89//! use nirv_engine::connectors::{RestConnector, AuthConfig, RateLimitConfig};
90//! use std::time::Duration;
91//!
92//! let connector = RestConnector::new()
93//!     .with_auth(AuthConfig::ApiKey {
94//!         header: "X-API-Key".to_string(),
95//!         key: "your-api-key".to_string(),
96//!     })
97//!     .with_cache_ttl(Duration::from_secs(300))
98//!     .with_rate_limit(RateLimitConfig {
99//!         requests_per_second: 10.0,
100//!         burst_size: 20,
101//!     });
102//! ```
103
104pub mod engine;
105pub mod connectors;
106pub mod protocol;
107pub mod cli;
108pub mod utils;
109
110pub use engine::*;
111pub use connectors::*;
112pub use protocol::*;
113pub use cli::*;
114pub use utils::*;