Skip to main content

zerodds_ast/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 ZeroDDS Contributors
3//! Crate `zerodds-ast`. Safety classification: **SAFE**.
4//!
5//! The common AST: one strictly typed model that every ZeroDDS type
6//! frontend lowers into and every backend reads from. A source-neutral
7//! core node space carries per-source typed facets, so a construct from
8//! IDL, XTypes, CORBA, ROS 2, DDS-XML or the FlatData model is
9//! representable without loss and without a stringly-typed escape hatch.
10//!
11//! ## Spec
12//!
13//! - `docs/specs/zerodds-ast-1.0.md` §3 (core node space), §4 (facets),
14//!   §8 (validation).
15//! - Feature sources: OMG IDL 4.2, DDS-XTypes 1.3, DDS-DCPS 1.4,
16//!   DDS-XML 1.0, DDS-RPC 1.0, CORBA 3.3, CCM 4.0, ROS 2 interface
17//!   definitions.
18//!
19//! ## Layer position
20//!
21//! Layer 1 — over `zerodds-ast-core`. Direct dependents:
22//! `zerodds-ast-layout`.
23#![no_std]
24#![forbid(unsafe_code)]
25
26extern crate alloc;
27
28// The unit-test harness itself needs std; the crate does not.
29#[cfg(test)]
30extern crate std;
31
32mod decimal;
33pub mod edit;
34pub mod error;
35pub mod facet;
36pub mod field;
37pub mod invariant;
38pub mod kind;
39pub mod model;
40pub mod node;
41pub mod profile;
42pub mod query;
43pub mod refs;
44mod resolve;
45pub mod snapshot;
46
47pub use edit::AstTransaction;
48pub use error::AstError;
49pub use facet::{
50    AppliedAnnotation, AppliedArgument, AutoId, ByteSpan, ComponentRole, CorbaFacet, CoreDxFacet,
51    DataRepresentationMask, Extensibility, Facets, FastDdsFacet, FlatDataFacet, HomeManages,
52    MacroExpansion, MemberIdAssignment, MemberIdOrigin, OpenDdsFacet, RangeConstraint,
53    RepositoryIdOrigin, Ros2Facet, RosBoundedOrigin, RosInterfaceRole, RtiFacet, SourceFacet,
54    SourceOrigin, StateVisibility, TemplateArg, TemplateParam, TemplateParamKind, TopicAnnotation,
55    TryConstruct, VendorFacets, VendorKind, VerbatimDirective, VerbatimPlacement, XTypesFacet,
56    XmlFacet,
57};
58/// The extensibility a type has when its source said nothing.
59///
60/// Appendable, not final: DDS-XTypes 1.3 §7.2.4.4. A consumer assuming
61/// final would emit types that cannot evolve.
62pub const DEFAULT_EXTENSIBILITY: facet::Extensibility = facet::Extensibility::Appendable;
63
64/// The bit bound an enum or bitmask has when its source said nothing.
65/// DDS-XTypes 1.3 §7.3.1.2.1.9.
66pub const DEFAULT_BIT_BOUND: u16 = 32;
67
68pub use invariant::InvariantViolation;
69pub use kind::NodeKind;
70pub use model::{Ast, MemberSpec, primitive};
71pub use node::{
72    AnnotationDefNode, AnnotationMemberNode, AnyId, AttributeNode, BinaryOp, BitValueNode,
73    BitfieldNode, Bound, CaseLabel, CaseNode, CharWidth, Completeness, ConstExpr, ConstExprNode,
74    ConstNode, ConstValue, DomainNode, EndpointNode, EndpointRole, EnumeratorNode, EvalError,
75    ExceptionNode, InterfaceKind, InterfaceNode, LibraryNode, Literal, MemberNode, ModuleNode,
76    OperationNode, ParamDirection, ParamNode, ParticipantNode, PrimitiveKind, QosPolicy,
77    QosPolicyKind, QosProfileNode, TopicNode, TypeKind, TypeNode, UnaryOp, ValuetypeKind,
78};
79pub use profile::{
80    ConstructKind, FacetProperty, Profile, ProfileViolation, Verdict, construct_verdict,
81    facet_verdict,
82};
83pub use refs::{PendingSlot, RefKind};
84pub use resolve::ResolveReport;