feat(typedef/crate-init): initialize alknet-typedef crate skeleton
Created crates/alknet-typedef/ with Cargo.toml depending on jsonschema 0.46 (default-features = false for WASM-cleanliness) and serde_json with preserve_order. Added src/lib.rs with module declarations for all 9 modules and skeleton source files for each. Added crate to workspace members list. Verified: cargo check, clippy -D warnings, and build --workspace all succeed. Dependency tree confirmed free of tokio/reqwest/rustls (WASM-clean).
This commit is contained in:
1 parent
db100f9849
commit
44f221e8cc
14 files changed
+378
-4
No files matched your search
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "alknet-typedef"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
description = "Binary struct engine: takes a JSON Schema with TypeDef:* custom keywords and produces an offset map, read/write functions, and validation"
|
||||
repository.workspace = true
|
||||
|
||||
[lib]
|
||||
name = "alknet_typedef"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
jsonschema = { version = "0.46", default-features = false }
|
||||
serde_json = { version = "1", features = ["preserve_order"] }
|
||||
@@ -0,0 +1,4 @@
|
||||
//! Data access layer: primitive read/write functions for all 17 TypeDef
|
||||
//! kinds with endianness support, bounds checking, and zero-copy access.
|
||||
|
||||
// TODO: implement
|
||||
@@ -0,0 +1,7 @@
|
||||
//! `TypedefEngine` — the compiled form of a schema.
|
||||
//!
|
||||
//! Combines the layout engine (both packed and aligned modes) and the
|
||||
//! jsonschema validator into a single struct. Built once at schema load
|
||||
//! time via [`TypedefEngine::compile`].
|
||||
|
||||
// TODO: implement
|
||||
@@ -0,0 +1,7 @@
|
||||
//! Error types for the typedef engine.
|
||||
//!
|
||||
//! Decided in ADR-098: a single `TypedefError` enum covers all error
|
||||
//! conditions across the engine's three phases (schema parsing, offset
|
||||
//! computation, read/write) plus validation.
|
||||
|
||||
// TODO: implement
|
||||
@@ -0,0 +1,9 @@
|
||||
//! Packed sequential `LayoutBuilder` — Mode 1 write-side (ADR-096).
|
||||
//!
|
||||
//! Fields are packed with no alignment padding. Variable-length fields
|
||||
//! shift all subsequent fields. The consumer provides actual data sizes
|
||||
//! for variable-length fields; the builder computes byte positions for
|
||||
//! each field. Used at write time when the consumer knows the data sizes
|
||||
//! upfront.
|
||||
|
||||
// TODO: implement
|
||||
@@ -0,0 +1,32 @@
|
||||
//! alknet-typedef: The binary struct engine.
|
||||
//!
|
||||
//! Takes a JSON Schema with `TypeDef:*` custom keywords 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
|
||||
//!
|
||||
//! - **Schema layer** ([`schema`]): TypeDef kind detection, annotation
|
||||
//! parsing, `$ref` normalization, endianness.
|
||||
//! - **Layout engine** ([`offset_map`], [`layout_builder`],
|
||||
//! [`sequential_reader`]): Two layout modes — aligned static for
|
||||
//! mmap-friendly formats, packed sequential for protocol wire formats.
|
||||
//! - **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.
|
||||
//! - **Validation** ([`validation`]): Custom keyword validators for all
|
||||
//! 17 `TypeDef:*` kinds, delegated to the `jsonschema` crate.
|
||||
//! - **Engine** ([`engine`]): `TypedefEngine` — the compiled form of a
|
||||
//! schema, combining layout and validation.
|
||||
|
||||
pub mod data_access;
|
||||
pub mod engine;
|
||||
pub mod error;
|
||||
pub mod layout_builder;
|
||||
pub mod offset_map;
|
||||
pub mod schema;
|
||||
pub mod sequential_reader;
|
||||
pub mod tunion;
|
||||
pub mod validation;
|
||||
@@ -0,0 +1,8 @@
|
||||
//! Aligned static `OffsetMap` — Mode 2 of the two layout modes (ADR-096).
|
||||
//!
|
||||
//! Fields have fixed positions with natural alignment padding.
|
||||
//! Variable-length fields get a 4-byte length prefix at a known offset;
|
||||
//! the variable data is not included in the static layout. Used for
|
||||
//! mmap-friendly formats (metatensor, safetensors).
|
||||
|
||||
// TODO: implement
|
||||
@@ -0,0 +1,6 @@
|
||||
//! Schema layer: TypeDef kind detection, annotation parsing, `$ref`
|
||||
//! normalization, and the `Endian` enum.
|
||||
//!
|
||||
//! Per ADR-097 and the schema-layer spec.
|
||||
|
||||
// TODO: implement
|
||||
@@ -0,0 +1,7 @@
|
||||
//! Packed sequential `SequentialReader` — Mode 1 read-side (ADR-096).
|
||||
//!
|
||||
//! Walks a buffer field-by-field according to the schema, reading length
|
||||
//! prefixes to determine variable-length data positions. Used at read
|
||||
//! time when the consumer is parsing an incoming frame.
|
||||
|
||||
// TODO: implement
|
||||
@@ -0,0 +1,7 @@
|
||||
//! TUnion discriminator dispatch (ADR-097 §4).
|
||||
//!
|
||||
//! TUnion supports two discriminator kinds: byte-offset (protocol
|
||||
//! dispatch, e.g., SFTP type bytes) and field-name (typedef.ts string
|
||||
//! pattern).
|
||||
|
||||
// TODO: implement
|
||||
@@ -0,0 +1,7 @@
|
||||
//! Custom keyword validators for all 17 `TypeDef:*` kinds, registered
|
||||
//! via `jsonschema::options().with_keyword(...)`.
|
||||
//!
|
||||
//! Per ADR-098: the `jsonschema` crate handles all structural validation;
|
||||
//! the custom keywords only validate leaf type constraints.
|
||||
|
||||
// TODO: implement
|
||||
Reference in new issue
Block a user