Skip to main content

things3_core/
lib.rs

1//! Things Core - Core library for Things 3 database access and data models
2//!
3//! This library provides high-performance access to the Things 3 database,
4//! with comprehensive data models and efficient querying capabilities.
5//!
6//! # Features
7//!
8//! - **Async Database Access**: Built on SQLx for type-safe, async database operations
9//! - **Comprehensive Data Models**: Full support for Tasks, Projects, Areas, and Tags
10//! - **Bulk Operations**: Efficient batch operations with transactional guarantees
11//! - **Caching Layer**: High-performance caching with configurable TTL
12//! - **Export Support**: Multiple export formats (JSON, CSV, OPML, Markdown, TaskPaper)
13//! - **Observability**: Built-in metrics, logging, and health checks
14//! - **Performance Monitoring**: Query performance tracking and optimization suggestions
15//!
16//! # Quick Start
17//!
18//! ```no_run
19//! use things3_core::{ThingsDatabase, ThingsError};
20//! use std::path::Path;
21//!
22//! # async fn example() -> Result<(), ThingsError> {
23//! // Connect to Things 3 database
24//! let db = ThingsDatabase::new(Path::new("/path/to/things.db")).await?;
25//!
26//! // Get inbox tasks
27//! let tasks = db.get_inbox(None).await?;
28//! println!("Found {} tasks in inbox", tasks.len());
29//!
30//! // Search for tasks
31//! let results = db.search_tasks("meeting").await?;
32//! println!("Found {} matching tasks", results.len());
33//! # Ok(())
34//! # }
35//! ```
36//!
37//! # Examples
38//!
39//! See the [examples directory](https://github.com/GarthDB/rust-things3/tree/main/examples)
40//! for more comprehensive usage examples.
41//!
42//! # Crate Features
43//!
44//! - `default`: Minimal feature set (core functionality only)
45//! - `export-csv`: Enable CSV export support
46//! - `export-opml`: Enable OPML export support
47//! - `export-taskpaper`: Enable TaskPaper export support
48//! - `export-ical`: Enable iCalendar (.ics) export support
49//! - `observability`: Enable metrics, tracing, and health checks
50//! - `full`: Enable all optional features
51//! - `test-utils`: Enable test utilities (for testing only)
52
53pub mod backup;
54pub mod cache;
55pub mod cache_invalidation_middleware;
56pub mod config;
57pub mod config_hot_reload;
58pub mod config_loader;
59pub mod database;
60pub mod disk_cache;
61pub mod error;
62
63#[cfg(feature = "advanced-queries")]
64pub mod filter_expr;
65
66#[cfg(feature = "batch-operations")]
67pub(crate) mod batch;
68
69#[cfg(feature = "batch-operations")]
70pub mod cursor;
71
72#[cfg(any(
73    feature = "export-csv",
74    feature = "export-opml",
75    feature = "export-taskpaper",
76    feature = "export-ical"
77))]
78pub mod export;
79
80pub mod mcp_cache_middleware;
81pub mod mcp_config;
82pub mod models;
83
84#[cfg(feature = "observability")]
85pub mod observability;
86
87pub mod performance;
88pub mod query;
89pub mod query_cache;
90pub mod query_performance;
91
92#[cfg(feature = "advanced-queries")]
93pub mod saved_queries;
94
95#[cfg(any(test, feature = "test-utils"))]
96pub mod test_utils;
97
98pub use backup::{BackupManager, BackupMetadata, BackupStats};
99pub use cache::{CacheConfig, CachePreloader, CacheStats, DefaultPreloader, ThingsCache};
100pub use cache_invalidation_middleware::{
101    CacheInvalidationHandler, CacheInvalidationMiddleware, InvalidationConfig, InvalidationEvent,
102    InvalidationEventType, InvalidationRule, InvalidationStats, InvalidationStrategy,
103    ThingsCacheInvalidationHandler,
104};
105pub use config::ThingsConfig;
106pub use config_hot_reload::{
107    ConfigChangeHandler, ConfigHotReloader, ConfigHotReloaderWithHandler,
108    DefaultConfigChangeHandler,
109};
110pub use config_loader::{load_config, load_config_from_env, load_config_with_paths, ConfigLoader};
111pub use database::{
112    get_default_database_path, ComprehensiveHealthStatus, DatabasePoolConfig, DatabaseStats,
113    PoolHealthStatus, PoolMetrics, SqliteOptimizations, ThingsDatabase,
114};
115pub use disk_cache::{DiskCache, DiskCacheConfig, DiskCacheStats};
116pub use error::{Result, ThingsError};
117
118#[cfg(any(
119    feature = "export-csv",
120    feature = "export-opml",
121    feature = "export-taskpaper",
122    feature = "export-ical"
123))]
124pub use export::{DataExporter, ExportConfig, ExportData, ExportFormat};
125
126pub use mcp_cache_middleware::{MCPCacheConfig, MCPCacheEntry, MCPCacheMiddleware, MCPCacheStats};
127pub use mcp_config::McpServerConfig;
128pub use models::*;
129// Explicitly re-export DeleteChildHandling for clarity
130pub use models::DeleteChildHandling;
131
132#[cfg(feature = "observability")]
133pub use observability::{
134    CheckResult, HealthStatus, ObservabilityConfig, ObservabilityError, ObservabilityManager,
135    ThingsMetrics,
136};
137
138pub use performance::{
139    CacheMetrics, ComprehensivePerformanceSummary, OperationMetrics, PerformanceMonitor,
140    PerformanceStats, PerformanceSummary, QueryMetrics,
141};
142pub use query_cache::{QueryCache, QueryCacheConfig, QueryCacheStats};
143
144#[cfg(feature = "advanced-queries")]
145pub use filter_expr::{FilterExpr, FilterPredicate};
146
147#[cfg(feature = "batch-operations")]
148pub use cursor::{Cursor, Page};
149pub use query_performance::{
150    ImplementationEffort, OptimizationPriority, OptimizationType, QueryContext,
151    QueryOptimizationSuggestion, QueryPerformanceMetrics, QueryPerformanceStats,
152    QueryPerformanceSummary, QueryPerformanceTracker,
153};
154#[cfg(feature = "advanced-queries")]
155pub use saved_queries::{SavedQuery, SavedQueryStore};
156
157/// Re-export commonly used types
158pub use chrono::{DateTime, NaiveDate, Utc};
159pub use serde::{Deserialize, Serialize};
160pub use uuid::Uuid;