Skip to main content

zerodds_types/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 ZeroDDS Contributors
3//! Crate `zerodds-types`. Safety classification: **SAFE**.
4//!
5//! OMG XTypes 1.3 Type-System — TypeIdentifier, TypeObject, Compatibility.
6//! Pure-Rust no_std + alloc, `forbid(unsafe_code)`.
7//!
8//! ## Spec
9//!
10//! - **OMG XTypes 1.3** §7.3.1 (TypeIdentifier), §7.3.4 (TypeIdentifier-Union)
11//! - **OMG XTypes 1.3** §7.3.4 (Minimal + Complete TypeObject)
12//! - **OMG XTypes 1.3** §7.3.5 (TypeInformation + Dependencies)
13//! - **OMG XTypes 1.3** §7.3.6 (TypeLookup Service IDL)
14//! - **OMG XTypes 1.3** §7.2.4 (assignability + compatibility rules)
15//! - **OMG XTypes 1.3** §7.6.3 (DynamicType ↔ TypeObject Bridge)
16//! - **OMG XTypes 1.3** §7.6.8 (KeyHash + EquivalenceHash via MD5)
17//! - **OMG DDS 1.4** §2.2.3 (TypeConsistencyEnforcement QoS-Policy)
18//!
19//! ## Layer position
20//!
21//! Layer 1 — primitives. Direct dependents: `zerodds-discovery`,
22//! `zerodds-dcps`, `zerodds-idl`, `zerodds-rpc`, `zerodds-xml`.
23//! Architecture + RFC: `internal/rfcs/0004-xtypes-integration.md`.
24//!
25//! ## Public-API modules
26//!
27//! - [`type_identifier`] — TypeIdentifier union (§7.3.4.2).
28//! - [`type_object`] — minimal + complete TypeObject (§7.3.4).
29//! - [`type_information`] — TypeInformation + dependencies (§7.3.5).
30//! - [`type_lookup`] — getTypes / getTypeDependencies IDL (§7.3.6).
31//! - [`builder`] — programmatic builder for all kinds.
32//! - [`hash`] — MD5 → 14-byte EquivalenceHash (§7.3.1.2.1).
33//! - [`resolve`] — TypeRegistry + alias resolution + DoS caps.
34//! - [`assignability`] — type-compatibility rules (§7.2.4).
35//! - [`type_matcher`] — writer↔reader matching with TCE policy
36//!   (§7.6.3.7 + §7.2.4).
37//! - [`qos`] — TypeConsistencyEnforcement + DataRepresentation
38//!   (DDS 1.4 §2.2.3).
39//! - [`dynamic`] — DynamicType / DynamicData reflection API
40//!   (§7.5) incl. DynamicType ↔ TypeObject bridge (§7.6.3).
41//!
42//! ## Wiring status
43//!
44//! `assignability` and `type_matcher` are **public API** for end-user
45//! code that does its own type-compatibility checks outside the DDS
46//! discovery pipeline (e.g. bridge implementations, custom schema
47//! registries). The ZeroDDS discovery pipeline currently matches by
48//! `type_name` (DDS 1.4 §2.2.3 default path); full XTypes 1.3 §7.6
49//! TypeIdentifier-aware discovery is its own cross-layer architecture
50//! epic (TypeIdentifier constants in codegen + SEDP propagation +
51//! TypeRegistry shared state).
52
53#![no_std]
54#![forbid(unsafe_code)]
55#![warn(missing_docs)]
56
57// `zerodds-types` mandatorily requires `alloc` — all modules use
58// `Vec`/`String`/`BTreeMap` for TypeObject containers. `zerodds-cdr` with
59// the `alloc` feature is a mandatory dep, so `extern crate alloc` is
60// always available.
61extern crate alloc;
62
63#[cfg(feature = "std")]
64extern crate std;
65
66pub mod assignability;
67pub mod builder;
68pub mod dynamic;
69pub mod error;
70pub mod hash;
71pub mod qos;
72pub mod resolve;
73pub mod type_identifier;
74pub mod type_information;
75pub mod type_lookup;
76pub mod type_matcher;
77#[cfg(test)]
78mod type_matcher_vectors;
79pub mod type_object;
80
81pub use error::TypeCodecError;
82pub use hash::{
83    compute_complete_hash, compute_hash, compute_minimal_hash, to_hashed_type_identifier,
84};
85pub use type_identifier::{
86    EquivalenceHash, EquivalenceKind, PlainCollectionHeader, PrimitiveKind,
87    StronglyConnectedComponentId, TypeIdentifier,
88};
89pub use type_information::{
90    TypeIdentifierWithDependencies, TypeIdentifierWithSize, TypeInformation,
91};
92pub use type_object::{CompleteTypeObject, MinimalTypeObject, TypeObject};