Expand description
Convert schemas between formats through a neutral hub (ADR-0064): every
format converts to/from twg_contract_core::schema::SchemaModel (structure)
so N formats cost N adapters, not N².
Implemented today: the protobuf → ODCS spoke —
FileDescriptorSet (.pb) → neutral schema → ODCS v3.1.0. The reverse
(ODCS → proto + .pb) and further spokes (JSON Schema, Avro) are planned; the
JSON Schema / Avro leaf-type mappings already exist in twg-type-map, which
becomes the leaf-type hub when those spokes are built.
use twg_schema_bridge::{descriptor_set_to_odcs, OdcsEmitOptions};
let pb = std::fs::read("bundle.pb").unwrap();
let opts = OdcsEmitOptions { id: "orders".into(), ..OdcsEmitOptions::default() };
let contract = descriptor_set_to_odcs(&pb, &opts)?;
std::fs::write("orders.odcs.json", contract.to_json_pretty().unwrap()).unwrap();Structs§
- Field
- One field of a
SchemaObject. - Odcs
Contract - A minimal ODCS v3.1.0 data contract, sufficient to describe a schema.
- Odcs
Emit Options - Contract-level metadata for the emitted ODCS document.
- Schema
Model - A complete set of schema objects that may reference each other by name.
- Schema
Object - One named record/message type.
Enums§
- Bridge
Error - Anything that can go wrong converting between schema formats.
- Cardinality
- How many values a field holds.
- Logical
Type - A leaf (scalar or reference) type, format-neutral but precise enough to reconstruct a source type (width/signedness preserved).
Functions§
- descriptor_
set_ to_ odcs - Convert a
FileDescriptorSet(.pb) directly into an ODCS v3.1.0 contract. - descriptor_
set_ to_ schema_ model - Decode a
FileDescriptorSetinto the neutral schema model. - schema_
model_ to_ odcs - Render a neutral schema model as an ODCS v3.1.0 contract.