Remove v0.1.0 custom-keyword machinery (step 8)
The BAST parser (step 3) and BAST-native validator (step 5) replaced the v0.1.0 custom-keyword accessor layer; step 7 moved the builder to BAST output. This step removes the now-dead code: Removed from src/schema.rs: - get_alktype_kind / get_alktype_kind_enum / get_alktype_kind_loose / get_alktype_kind_loose_enum (replaced by the BAST parser's kind dispatch) - normalize_refs / inline_union_variant_refs + helpers (BAST refs are always #/$defs/<name>; resolution is a single hash lookup, variant refs resolve lazily) - parse_encoding / parse_align / parse_max_length / parse_endian (bast.rs has its own BAST-property-form copies) - parse_discriminator + DiscriminatorKind (replaced by bast::BastDiscriminator; builder has its own Discriminator enum) - resolve_ref / resolve_ref_or_inline (replaced by BastDoc::lookup_def / resolve_typeref) - FromStr impl, as_str, Endian::from_schema, ALKTYPE_PREFIX, BYTE_DISCRIMINATOR_TYPES, and the associated unit tests Kept: AlkTypeKind enum + methods (type_size, natural_alignment, is_fixed_size, needs_endian, is_composite, is_variable_length, to_bast_str, from_bast_str), Display (now backed by to_bast_str), Endian, VariableEncoding, U32_SIZE, DISCRIMINATOR_PATH. src/lib.rs: dropped the 13 schema::* helper re-exports and DiscriminatorKind from the public surface; kept Endian, AlkTypeKind, VariableEncoding. Doc/comment updates: bast.rs, builder.rs, engine.rs, error.rs — removed references to the deleted functions and the AlkType:* keyword form. The jsonschema crate remains a dependency (validate_json path + BAST meta-schema validation); build_validator was already repurposed in step 6 (no custom keywords). Verification: - cargo test --release: 389 pass (312 lib + 77 integration) - cargo clippy --all-targets -- -D warnings: clean - cargo doc --no-deps: clean - cargo build --target wasm32-unknown-unknown --release: clean
This commit is contained in:
1 parent
45f3336201
commit
54fd112fde
6 files changed
+51
-845
No files matched your search
+17
-20
@@ -1,7 +1,6 @@
|
||||
//! BAST document parser — the typed surface over a BAST (Binary Abstract
|
||||
//! Syntax Tree) document that the layout engines, materializer, and
|
||||
//! BAST-native validator walk instead of the v0.1.0 `get_alktype_kind*`
|
||||
//! custom-keyword accessors.
|
||||
//! BAST-native validator walk.
|
||||
//!
|
||||
//! This is step 3 of the BAST pivot
|
||||
//! ([`docs/plans/bast-implementation.md`](../docs/plans/bast-implementation.md)).
|
||||
@@ -19,11 +18,10 @@
|
||||
//! parse allocation-free beyond the small typed nodes themselves.
|
||||
//!
|
||||
//! `$ref` resolution is a single hash lookup against `$defs` — BAST refs
|
||||
//! are always full JSON Pointers restricted to `#/$defs/<name>` (no
|
||||
//! `normalize_refs`, no `inline_union_variant_refs`; both are removed in
|
||||
//! step 8). Union variant `$ref`s are resolved **lazily** by the
|
||||
//! materializer/validator via [`BastDoc::resolve_typeref`]; the parser
|
||||
//! only records the [`BastRef`] target name.
|
||||
//! are always full JSON Pointers restricted to `#/$defs/<name>`. Union
|
||||
//! variant `$ref`s are resolved **lazily** by the materializer/validator
|
||||
//! via [`BastDoc::resolve_typeref`]; the parser only records the
|
||||
//! [`BastRef`] target name.
|
||||
//!
|
||||
//! ## Untrusted input
|
||||
//!
|
||||
@@ -91,8 +89,8 @@ impl<'a> BastDoc<'a> {
|
||||
|
||||
/// Look up a raw `$defs` entry by name. Returns the raw JSON node.
|
||||
///
|
||||
/// The single hash lookup that replaces v0.1.0's `normalize_refs` +
|
||||
/// `resolve_ref` machinery. BAST refs are always `#/$defs/<name>`;
|
||||
/// The single hash lookup that replaces v0.1.0's ref-normalization
|
||||
/// machinery. BAST refs are always `#/$defs/<name>`;
|
||||
/// no external refs, no fragment-only pointers, no bare names.
|
||||
pub fn lookup_def(&self, name: &str) -> Result<&'a Value, AlkTypeError> {
|
||||
Self::lookup_def_raw(self.root, name)
|
||||
@@ -102,8 +100,8 @@ impl<'a> BastDoc<'a> {
|
||||
///
|
||||
/// Used lazily by the materializer and BAST-native validator (step 5)
|
||||
/// for union variant dispatch and `$ref` fields. The parser does not
|
||||
/// inline refs at construction time — this is the replacement for
|
||||
/// v0.1.0's `inline_union_variant_refs`.
|
||||
/// inline refs at construction time — variant refs stay as
|
||||
/// [`BastRef`]s and resolve on demand.
|
||||
pub fn resolve_ref(&self, r: &BastRef<'a>) -> Result<BastDef<'a>, AlkTypeError> {
|
||||
let raw = self.lookup_def(r.name())?;
|
||||
BastDef::parse(raw, r.name(), "")
|
||||
@@ -440,8 +438,7 @@ impl<'a> BastField<'a> {
|
||||
/// discriminator.
|
||||
///
|
||||
/// Variant `$ref`s are resolved **lazily** by the materializer/validator
|
||||
/// via [`BastDoc::resolve_typeref`] — no compile-time inlining (the
|
||||
/// replacement for v0.1.0's `inline_union_variant_refs`).
|
||||
/// via [`BastDoc::resolve_typeref`] — no compile-time inlining.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BastUnion<'a> {
|
||||
endian: Endian,
|
||||
@@ -774,8 +771,8 @@ impl<'a> BastType<'a> {
|
||||
/// A `$ref` to a named `$defs` entry, restricted to `#/$defs/<name>`.
|
||||
///
|
||||
/// The restriction keeps resolution a single hash lookup
|
||||
/// ([`BastDoc::lookup_def`]) and eliminates the `normalize_refs` step
|
||||
/// the v0.1.0 engine needed for TypeBox's bare-name refs.
|
||||
/// ([`BastDoc::lookup_def`]); the v0.1.0 engine needed a normalization
|
||||
/// pass for TypeBox's bare-name refs, but BAST forbids them.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BastRef<'a> {
|
||||
name: &'a str,
|
||||
@@ -892,11 +889,11 @@ impl<'a> BastRecord<'a> {
|
||||
// Shared annotation parsers (BAST-property form).
|
||||
//
|
||||
// These read type-level/field-level properties (`endian`, `align`,
|
||||
// `encoding`, `maxLength`) directly off a BAST node, instead of the
|
||||
// v0.1.0 keyword-value objects that `schema::parse_*` read. Their
|
||||
// *semantics* are unchanged (ADR-003); only the input location moved.
|
||||
// They're `fn`s rather than methods on the typed nodes so the layout
|
||||
// engines can call them on raw `&Value` during the step 4 migration.
|
||||
// `encoding`, `maxLength`) directly off a BAST node. Their *semantics*
|
||||
// are unchanged (ADR-003); only the input location moved from the
|
||||
// v0.1.0 keyword-value objects to BAST type-level properties. They're
|
||||
// `fn`s rather than methods on the typed nodes so the layout engines
|
||||
// can call them on raw `&Value` during the step 4 migration.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
fn parse_endian_opt(node: &Value) -> Option<Endian> {
|
||||
|
||||
Reference in new issue
Block a user