oxigeo_core/lib.rs
1//! `OxiGeo` Core - Pure Rust Geospatial Abstractions
2//!
3//! This crate provides the core types and traits for the `OxiGeo` ecosystem,
4//! a pure Rust reimplementation of GDAL for cloud-native geospatial computing.
5//!
6//! # Features
7//!
8//! - `std` (default) - Enable standard library support
9//! - `alloc` - Enable allocation support without full std
10//! - `arrow` - Enable Apache Arrow integration for zero-copy buffers
11//! - `async` - Enable async I/O traits
12//!
13//! # Core Types
14//!
15//! - [`BoundingBox`] - 2D spatial extent
16//! - [`GeoTransform`] - Affine transformation for georeferencing
17//! - [`RasterDataType`] - Pixel data types
18//! - [`buffer::RasterBuffer`] - Typed raster data buffer
19//!
20//! # Example
21//!
22//! ```
23//! use oxigeo_core::types::{BoundingBox, GeoTransform, RasterDataType};
24//! use oxigeo_core::buffer::RasterBuffer;
25//! use oxigeo_core::error::Result;
26//!
27//! # fn main() -> Result<()> {
28//! // Create a bounding box
29//! let bbox = BoundingBox::new(-180.0, -90.0, 180.0, 90.0)?;
30//!
31//! // Create a geotransform for a 1-degree resolution grid
32//! let gt = GeoTransform::from_bounds(&bbox, 360, 180)?;
33//!
34//! // Create a raster buffer
35//! let buffer = RasterBuffer::zeros(360, 180, RasterDataType::Float32);
36//! # Ok(())
37//! # }
38//! ```
39
40#![cfg_attr(not(feature = "std"), no_std)]
41#![warn(missing_docs)]
42#![warn(clippy::all)]
43// Pedantic disabled to reduce noise - default clippy::all is sufficient
44// #![warn(clippy::pedantic)]
45#![deny(clippy::unwrap_used)]
46#![allow(clippy::module_name_repetitions)]
47
48extern crate alloc;
49
50#[cfg(feature = "std")]
51extern crate std;
52
53/// Internal prelude that makes `alloc`-provided types and macros available in
54/// `no_std` builds.
55///
56/// Under the `std` feature these names come from the standard prelude, so this
57/// module is only wired in for `no_std` (`#[cfg(not(feature = "std"))]`) to keep
58/// the `std` build byte-for-byte identical. Modules that use bare `Vec`,
59/// `String`, `Box`, `format!` or `vec!` add
60/// `#[cfg(not(feature = "std"))] use crate::compat::*;` at their top.
61#[cfg(not(feature = "std"))]
62#[allow(unused_imports)]
63pub(crate) mod compat {
64 pub use alloc::borrow::ToOwned;
65 pub use alloc::boxed::Box;
66 pub use alloc::string::{String, ToString};
67 pub use alloc::vec::Vec;
68 pub use alloc::{format, vec};
69}
70
71pub mod buffer;
72pub mod error;
73pub mod io;
74// Portable floating-point helpers (`libm`-backed on `no_std`). The module body
75// is empty under `std`, so this has no effect on hosted builds.
76pub(crate) mod math;
77// The advanced memory-management module (custom allocators, memory-mapped I/O,
78// NUMA/huge-page support) relies on `parking_lot`, hashed collections, the global
79// allocator and OS primitives, so it requires the standard library.
80#[cfg(feature = "std")]
81pub mod memory;
82pub mod simd_buffer;
83pub mod types;
84pub mod vector;
85
86// Tutorial documentation
87pub mod tutorials;
88
89// Re-export commonly used items
90pub use error::{OxiGeoError, Result};
91#[cfg(feature = "std")]
92pub use io::{Dataset, FieldType, RasterDataset, VectorDataset};
93pub use types::{
94 BoundingBox, ColorEntry, ColorTable, ColorTableKind, CrsFormat, GeoTransform, Histogram,
95 RasterDataType, RasterMetadata, SpatialReference, Statistics,
96};
97pub use vector::FieldValue;
98
99pub use buffer::Mask;
100pub use buffer::{
101 FloatToIntRounding, RasterElement, RasterElementKind, convert_raw_bytes, convert_raw_into,
102 convert_raw_into_with, elements_as_bytes,
103};
104#[cfg(feature = "std")]
105pub use io::{MmapDataSource, MmapDataSourceRw};
106
107/// Crate version
108pub const VERSION: &str = env!("CARGO_PKG_VERSION");
109
110/// Crate name
111pub const NAME: &str = env!("CARGO_PKG_NAME");
112
113#[cfg(test)]
114mod tests {
115 use super::*;
116
117 #[test]
118 fn test_version() {
119 assert!(!VERSION.is_empty());
120 assert_eq!(NAME, "oxigeo-core");
121 }
122}