geometry_tag/lib.rs
1//! Geometry kind tags and the tag-hierarchy marker traits.
2//!
3//! Eleven empty tag types identify each OGC geometry kind, and a set of
4//! marker traits (`Single`, `Multi`, `Pointlike`, `Linear`, `Polylinear`,
5//! `Areal`, `Polygonal`, `Volumetric`) reproduce the C++ struct-inheritance
6//! hierarchy at the Rust trait-bound level. Together they let downstream
7//! crates dispatch on tag *identity* (one impl per tag) and tag *category*
8//! (one impl that covers every linear tag, every areal tag, etc.) — the
9//! Rust analogue of `tag_cast<Tag, Stops...>`.
10//!
11//! References:
12//! - `boost/geometry/core/tags.hpp` — tag hierarchy declarations.
13//! - `boost/geometry/core/tag.hpp` — the `traits::tag<G>::type` metafunction.
14//! - `boost/geometry/core/tag_cast.hpp` — base-tag walking, replaced here
15//! by Rust trait super-bounds.
16//!
17//! # Examples
18//!
19//! Category dispatch — one impl covers every linear tag:
20//!
21//! ```
22//! use geometry_tag::{Linear, LinestringTag, MultiLinestringTag, SegmentTag};
23//!
24//! fn accepts_linear<T: Linear>() {}
25//! accepts_linear::<SegmentTag>();
26//! accepts_linear::<LinestringTag>();
27//! accepts_linear::<MultiLinestringTag>();
28//! ```
29
30#![no_std]
31#![forbid(unsafe_code)]
32
33mod hierarchy;
34mod same_as;
35mod tag;
36
37pub use hierarchy::{Areal, Linear, Multi, Pointlike, Polygonal, Polylinear, Single, Volumetric};
38pub use same_as::SameAs;
39pub use tag::{
40 BoxTag, DynamicGeometryTag, GeometryCollectionTag, LinestringTag, MultiLinestringTag,
41 MultiPointTag, MultiPolygonTag, PointTag, PolygonTag, PolyhedralSurfaceTag, RingTag,
42 SegmentTag,
43};