//! alktype: The binary struct engine. //! //! Takes a BAST (Binary Abstract Syntax Tree) document and produces //! an offset map, read/write functions, and validation — all driven //! by the schema. The schema is the format definition; the engine is //! generic. //! //! ## Architecture //! //! - **BAST parser** ([`bast`]): Typed tree over a BAST document — //! `BastDoc`/`BastDef`/`BastStruct`/`BastField`/`BastType`/etc. //! Owns its data (ADR-012 §2a) so consumers (`AlkTypeEngine`, //! `LayoutBuilder`) can store the parsed tree without lifetime //! entanglement; the clone happens once at `BastDoc::new`. //! - **Layout engine** ([`offset_map`], [`layout_builder`], //! [`sequential_reader`], [`read_plan`]): Two layout modes — aligned //! static for mmap-friendly formats, packed sequential for protocol //! wire formats. All consume the BAST typed tree; `read_plan` is the //! packed read-side compiled form (ADR-011). //! - **Data access** ([`data_access`]): Typed read/write at computed //! offsets, zero-copy for fixed-size types. //! - **TUnion dispatch** ([`tunion`]): Byte-offset and field-name //! discriminator dispatch over `BastUnion`. //! - **Validation** ([`validation`], [`bast_validation`], //! [`validation_plan`]): two validators for two paths. //! `validation_plan` is the compiled `ValidationPlan` — a //! compile-once-walk-many constraint tree over the BAST document's //! value-domain constraints, walked by `validate_bytes` per buffer //! without re-touching the document (ADR-012 §3). `bast_validation` //! hosts the one-shot `validate_value` wrapper over the plan. //! `validation` builds a standard `jsonschema::Validator` from a //! consumer-provided JSON Schema for `validate_json` / //! `is_valid_json` (D-BAST-007) — no custom keywords, no BAST //! involvement. //! - **Builder** ([`builder`]): Fluent Rust API for constructing BAST //! documents (binary layout) and standard JSON Schemas (JSON //! validation) at runtime, producing `serde_json::Value` (ADR-009, //! D-BAST-008). `struct_()` → BAST, `object()` → standard JSON Schema. //! - **Materialize** ([`materialize`]): Materialize a `serde_json::Value` //! tree from a binary buffer by walking the BAST typed tree. Used by //! `AlkTypeEngine::validate_bytes` (ADR-010). //! - **Engine** ([`engine`]): `AlkTypeEngine` — the compiled form of a //! BAST document, combining layout and validation. #[macro_use] mod macros; pub mod bast; pub mod bast_meta; pub mod bast_validation; pub mod builder; pub mod data_access; pub mod engine; pub mod error; pub mod layout_builder; pub mod materialize; pub mod offset_map; pub mod read_plan; pub mod schema; pub mod sequential_reader; pub mod tunion; pub mod validation; pub mod validation_plan; pub use bast_meta::BAST_META_SCHEMA; pub use bast::{ BastArray, BastDef, BastDefKind, BastDiscriminator, BastDoc, BastEnum, BastField, BastRef, BastRecord, BastStruct, BastType, BastUnion, }; pub use builder::{Definitions, Discriminator, Schema}; pub use engine::{LayoutMode, AlkTypeEngine}; pub use error::AlkTypeError; pub use layout_builder::{FieldPosition, LayoutBuilder, PackedLayout}; pub use offset_map::{ByteRange, OffsetMap}; pub use read_plan::{ CompositePlan, DiscriminatorPlan, FieldPlan, ReadKind, ReadPlan, }; pub use schema::{Endian, AlkTypeKind, VariableEncoding}; pub use sequential_reader::{FieldValue, SequentialReader}; pub use tunion::UnionDispatch; pub use validation::build_validator; pub use validation_plan::{ValidField, ValidNode, ValidVariant, ValidationPlan};