1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Protocol Buffer schema registry for scirs2-io.
//!
//! This module provides a self-contained, pure-Rust Protocol Buffer schema
//! registry. It does **not** depend on `prost`, `protobuf`, or any other
//! code-generation tool, in accordance with the COOLJAPAN pure-Rust policy.
//!
//! # Overview
//!
//! The registry stores versioned [`MessageDescriptor`]s identified by
//! auto-assigned [`SchemaId`]s. Consumers can:
//!
//! * **Register** a brand-new schema and receive its `SchemaId`.
//! * **Evolve** an existing schema by registering a new version, subject to
//! backward-compatibility validation.
//! * **Retrieve** the latest (or a specific) version of a schema.
//! * **Encode / decode** concrete Protocol Buffer messages against a schema.
//! * **Export / import** the entire registry as JSON.
//!
//! # Quick start
//!
//! ```rust
//! use scirs2_io::schema_registry::{
//! registry::SchemaRegistry,
//! types::{FieldDescriptor, FieldType, FieldValue, MessageDescriptor, RegistryConfig},
//! wire::{decode_message, encode_message},
//! };
//!
//! // 1. Create a registry and register a schema
//! let mut reg = SchemaRegistry::new(RegistryConfig::default());
//!
//! let person = MessageDescriptor::new("Person", "example")
//! .with_field(FieldDescriptor::optional(1, "id", FieldType::Int64))
//! .with_field(FieldDescriptor::optional(2, "name", FieldType::String));
//!
//! let id = reg.register(person.clone()).unwrap();
//! assert_eq!(reg.get(id).unwrap().version.value(), 1);
//!
//! // 2. Encode a message
//! let values = vec![
//! (1, FieldValue::Int64(42)),
//! (2, FieldValue::Str("Alice".to_string())),
//! ];
//! let bytes = encode_message(&person, &values);
//!
//! // 3. Decode it back
//! let decoded = decode_message(&person, &bytes).unwrap();
//! assert_eq!(decoded[0].0, "id");
//! assert_eq!(decoded[1].1, FieldValue::Str("Alice".to_string()));
//! ```
//!
//! # Sub-modules
//!
//! | Module | Description |
//! |--------|-------------|
//! | [`types`] | Core types: `SchemaId`, `FieldType`, `MessageDescriptor`, etc. |
//! | [`registry`] | [`SchemaRegistry`] — versioned schema storage and compatibility checks |
//! | [`wire`] | Pure-Rust proto wire format encoder / decoder |
//! | [`validation`] | Structural validation of message descriptors |
// ─── Convenience re-exports ───────────────────────────────────────────────────
pub use SchemaRegistry;
pub use ;
pub use validate_descriptor;
pub use ;