spatio/
lib.rs

1//! Embedded spatio-temporal database with 2D/3D indexing and persistence.
2//!
3//! ## Features
4//! - **Spatial indexing**: 2D/3D points, polygons, bounding boxes with R*-tree spatial indexing
5//! - **Persistence**: Append-only file (AOF) with configurable sync policies
6//! - **Atomic batches**: Group multiple operations atomically
7//! - **Temporal queries**: Filter by creation time (with `time-index` feature)
8//!
9//! ## Example
10//! ```
11//! use spatio::{Point3d, Spatio};
12//!
13//! let db = Spatio::memory()?;
14//!
15//! // Spatial example
16//! let point = Point3d::new(-74.0060, 40.7128, 0.0);
17//! db.upsert("cities", "nyc", point.clone(), serde_json::json!({"name": "NYC"}), None)?;
18//! let nearby = db.query_radius("cities", &point, 1000.0, 10)?;
19//!
20//! # Ok::<(), spatio::SpatioError>(())
21//! ```
22
23pub mod builder;
24pub mod compute;
25pub mod config;
26pub mod db;
27pub mod error;
28
29pub use builder::DBBuilder;
30pub use db::DB;
31pub use error::{Result, SpatioError};
32
33#[cfg(feature = "sync")]
34pub use db::SyncDB;
35
36#[doc(inline)]
37pub use db::DB as Spatio;
38
39pub use geo::Rect;
40pub use spatio_types::geo::{Point, Polygon};
41
42pub use config::{
43    BoundingBox2D, BoundingBox3D, Config, DbStats, Point3d, Polygon3D, PolygonDynamic,
44    PolygonDynamic3D, SetOptions, SyncMode, SyncPolicy, TemporalBoundingBox2D,
45    TemporalBoundingBox3D, TemporalPoint, TemporalPoint3D,
46};
47
48pub use compute::spatial::DistanceMetric;
49#[cfg(feature = "time-index")]
50pub use config::{HistoryEntry, HistoryEventKind};
51
52pub use db::{Namespace, NamespaceManager};
53
54pub use compute::validation;
55
56pub const VERSION: &str = env!("CARGO_PKG_VERSION");
57
58/// Common imports
59pub mod prelude {
60
61    pub use crate::{DBBuilder, Result, Spatio, SpatioError};
62
63    #[cfg(feature = "sync")]
64    pub use crate::SyncDB;
65
66    pub use crate::{Point, Polygon};
67    pub use geo::Rect;
68
69    pub use crate::{Config, SetOptions, SyncPolicy};
70
71    pub use crate::{Namespace, NamespaceManager};
72
73    pub use crate::validation;
74
75    pub use std::time::Duration;
76}