oxedyne/fe2o3/fe2o3_datime/src/database/mod.rs
1.7 KiB, 63 runs
created by r1870400018:8432, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | //! Database integration and storage format methods for datetime types. |
| 2 | //! |
| 3 | //! This module provides comprehensive database storage and retrieval methods |
| 4 | //! for CalClock, ClockTime, CalendarDate, and related datetime types. |
| 5 | //! Multiple storage formats are supported to optimise for different use cases: |
| 6 | //! |
| 7 | //! - **Binary format**: Most efficient for time-based queries and storage |
| 8 | //! - **ISO 8601 strings**: Human-readable and standard-compliant |
| 9 | //! - **Component format**: Optimal for partial queries and filtering |
| 10 | //! - **Unix timestamps**: Compatible with existing systems |
| 11 | //! |
| 12 | //! # Storage Strategies |
| 13 | //! |
| 14 | //! ## CalClock Storage |
| 15 | //! - Primary: Nanosecond timestamp + timezone ID |
| 16 | //! - Secondary: ISO 8601 string for readability |
| 17 | //! - Indexed: Year/month/day components for calendar queries |
| 18 | //! |
| 19 | //! ## ClockTime Storage |
| 20 | //! - Primary: Nanoseconds since midnight + timezone |
| 21 | //! - Secondary: Hour/minute/second components |
| 22 | //! |
| 23 | //! ## CalendarDate Storage |
| 24 | //! - Primary: Julian day number + timezone |
| 25 | //! - Secondary: Year/month/day components |
| 26 | //! |
| 27 | //! # Examples |
| 28 | //! |
| 29 | //! ```ignore |
| 30 | //! use oxedyne_fe2o3_datime::{ |
| 31 | //! time::{CalClock, CalClockZone}, |
| 32 | //! database::{DatabaseRecord, StorageFormat}, |
| 33 | //! }; |
| 34 | //! |
| 35 | //! let zone = CalClockZone::utc(); |
| 36 | //! let calclock = CalClock::new(2024, 6, 15, 14, 30, 0, 0, zone)?; |
| 37 | //! |
| 38 | //! // Convert to database record |
| 39 | //! let record = calclock.to_database_record(StorageFormat::Binary)?; |
| 40 | //! |
| 41 | //! // Restore from database |
| 42 | //! let restored = CalClock::from_database_record(&record)?; |
| 43 | //! assert_eq!(calclock, restored); |
| 44 | //! ``` |
| 45 | //! |
| 46 | //! [Written with AI entirely](https://need2know.ai/entirely-ai/code)\ |
| 47 | //! Anthropic Claude |
| 48 | |
| 49 | pub mod storage; |
| 50 | pub mod formats; |
| 51 | pub mod indexes; |
| 52 | |
| 53 | pub use storage::*; |
| 54 | pub use formats::*; |
| 55 | pub use indexes::*; |