spatio/
lib.rs

1//! Embedded spatio-temporal database with 2D/3D indexing, persistence, and TTL support.
2//!
3//! ```rust
4//! use spatio::{Point, Spatio};
5//!
6//! let db = Spatio::memory()?;
7//! db.insert("key", b"value", None)?;
8//!
9//! let point = Point::new(-74.0060, 40.7128);
10//! db.insert_point("cities", &point, b"NYC", None)?;
11//! let nearby = db.query_within_radius("cities", &point, 1000.0, 10)?;
12//! # Ok::<(), spatio::SpatioError>(())
13//! ```
14
15pub mod builder;
16pub mod compute;
17pub mod config;
18pub mod db;
19pub mod error;
20pub mod ffi;
21pub mod storage;
22
23pub use builder::DBBuilder;
24pub use db::DB;
25pub use error::{Result, SpatioError};
26
27pub type Spatio = DB;
28
29pub use geo::{Point, Polygon, Rect};
30
31pub use compute::{
32    BBoxQuery, CylinderQuery, DistanceMetric, bounding_box, convex_hull, distance_between, knn,
33};
34
35pub use config::{
36    BoundingBox2D, BoundingBox3D, Config, DbStats, Point3d, Polygon3D, PolygonDynamic,
37    PolygonDynamic3D, SetOptions, SyncMode, SyncPolicy, TemporalBoundingBox2D,
38    TemporalBoundingBox3D, TemporalPoint, TemporalPoint3D, Trajectory, Trajectory3D,
39};
40#[cfg(feature = "time-index")]
41pub use config::{HistoryEntry, HistoryEventKind};
42
43pub use db::{AtomicBatch, Namespace, NamespaceManager};
44
45pub use storage::{MemoryBackend, StorageBackend, StorageOp, StorageStats};
46
47#[cfg(feature = "aof")]
48pub use storage::AOFBackend;
49
50#[cfg(feature = "aof")]
51pub use storage::{AOFConfig, AOFFile};
52
53pub const VERSION: &str = env!("CARGO_PKG_VERSION");
54
55/// Common imports
56pub mod prelude {
57
58    pub use crate::{DBBuilder, Result, Spatio, SpatioError};
59
60    pub use geo::{Point, Polygon, Rect};
61
62    pub use crate::compute::{DistanceMetric, bounding_box, distance_between, knn};
63
64    pub use crate::{Config, SetOptions, SyncPolicy};
65
66    pub use crate::{AtomicBatch, Namespace, NamespaceManager};
67
68    pub use crate::{MemoryBackend, StorageBackend};
69
70    #[cfg(feature = "aof")]
71    pub use crate::AOFBackend;
72
73    pub use std::time::Duration;
74}