pub struct TypeSchemaBuilder { /* private fields */ }Expand description
Builder for creating type schemas fluently
Implementations§
Source§impl TypeSchemaBuilder
impl TypeSchemaBuilder
Sourcepub fn decimal_field(self, name: impl Into<String>) -> Self
pub fn decimal_field(self, name: impl Into<String>) -> Self
Add a decimal field (stored as f64, reconstructed as Decimal on read)
Sourcepub fn bool_field(self, name: impl Into<String>) -> Self
pub fn bool_field(self, name: impl Into<String>) -> Self
Add a boolean field
Sourcepub fn string_field(self, name: impl Into<String>) -> Self
pub fn string_field(self, name: impl Into<String>) -> Self
Add a string field
Sourcepub fn timestamp_field(self, name: impl Into<String>) -> Self
pub fn timestamp_field(self, name: impl Into<String>) -> Self
Add a timestamp field
Sourcepub fn object_field(
self,
name: impl Into<String>,
type_name: impl Into<String>,
) -> Self
pub fn object_field( self, name: impl Into<String>, type_name: impl Into<String>, ) -> Self
Add a nested object field
Sourcepub fn array_field(
self,
name: impl Into<String>,
element_type: FieldType,
) -> Self
pub fn array_field( self, name: impl Into<String>, element_type: FieldType, ) -> Self
Add an array field
Sourcepub fn hashmap_field(
self,
name: impl Into<String>,
key_type: FieldType,
value_type: FieldType,
) -> Self
pub fn hashmap_field( self, name: impl Into<String>, key_type: FieldType, value_type: FieldType, ) -> Self
Add a HashMap<K, V> field. W17.3-4.1 — per audit §4.B builder
parity with array_field. Slot storage points to
HeapKind::HashMap; the schema-side variant carries the static
K/V FieldTypes for compile-time checking (ADR-006 §2.7.5).
Sourcepub fn set_field(self, name: impl Into<String>, element_type: FieldType) -> Self
pub fn set_field(self, name: impl Into<String>, element_type: FieldType) -> Self
Add a Setarray_field. Slot storage points to HeapKind::HashSet;
the schema-side variant carries the static element FieldType
for compile-time checking (ADR-006 §2.7.5).
Sourcepub fn field_with_meta(
self,
name: impl Into<String>,
field_type: FieldType,
annotations: Vec<FieldAnnotation>,
) -> Self
pub fn field_with_meta( self, name: impl Into<String>, field_type: FieldType, annotations: Vec<FieldAnnotation>, ) -> Self
Add a field with annotation metadata
Sourcepub fn build(self) -> TypeSchema
pub fn build(self) -> TypeSchema
Build the type schema
Sourcepub fn register(self, registry: &mut TypeSchemaRegistry) -> SchemaId
pub fn register(self, registry: &mut TypeSchemaRegistry) -> SchemaId
Build and register in a registry, using the registry’s per-instance schema-ID counter.
Since B1.7 this path must not consult current_registry, because
DEFAULT_SCHEMA_REGISTRY is itself initialized via this builder
and that would cause a recursive LazyLock init. Allocating
directly from the target registry keeps bootstrap deterministic
and per-registry isolated.