pub struct TypeSchemaRegistry { /* private fields */ }Expand description
Global registry of type schemas
Implementations§
Source§impl TypeSchemaRegistry
impl TypeSchemaRegistry
Sourcepub fn register(&mut self, schema: TypeSchema)
pub fn register(&mut self, schema: TypeSchema)
Register a type schema
Sourcepub fn register_type(
&mut self,
name: impl Into<String>,
fields: Vec<(String, FieldType)>,
) -> SchemaId
pub fn register_type( &mut self, name: impl Into<String>, fields: Vec<(String, FieldType)>, ) -> SchemaId
Register a type with field definitions
Sourcepub fn get(&self, name: &str) -> Option<&TypeSchema>
pub fn get(&self, name: &str) -> Option<&TypeSchema>
Get schema by name
Sourcepub fn get_by_id(&self, id: SchemaId) -> Option<&TypeSchema>
pub fn get_by_id(&self, id: SchemaId) -> Option<&TypeSchema>
Get schema by ID
Sourcepub fn max_schema_id(&self) -> Option<SchemaId>
pub fn max_schema_id(&self) -> Option<SchemaId>
Highest schema ID currently stored in this registry.
Sourcepub fn field_offset(&self, type_name: &str, field_name: &str) -> Option<usize>
pub fn field_offset(&self, type_name: &str, field_name: &str) -> Option<usize>
Get field offset for a type/field combination
Sourcepub fn type_count(&self) -> usize
pub fn type_count(&self) -> usize
Number of registered types
Sourcepub fn type_names(&self) -> impl Iterator<Item = &str>
pub fn type_names(&self) -> impl Iterator<Item = &str>
Iterator over all registered type names
Sourcepub fn with_stdlib_types() -> Self
pub fn with_stdlib_types() -> Self
Create a registry with common stdlib types pre-registered
Sourcepub fn with_stdlib_types_and_builtin_ids() -> (Self, BuiltinSchemaIds)
pub fn with_stdlib_types_and_builtin_ids() -> (Self, BuiltinSchemaIds)
Create a registry with stdlib types and return both registry and builtin IDs.
Sourcepub fn compute_all_hashes(&mut self)
pub fn compute_all_hashes(&mut self)
Compute content hashes for all registered schemas.
Sourcepub fn get_by_content_hash(&self, hash: &[u8; 32]) -> Option<&TypeSchema>
pub fn get_by_content_hash(&self, hash: &[u8; 32]) -> Option<&TypeSchema>
Look up a schema by its content hash.
Returns the first schema whose cached or computed content hash matches.
For best performance, call compute_all_hashes first.
Sourcepub fn merge(&mut self, other: TypeSchemaRegistry)
pub fn merge(&mut self, other: TypeSchemaRegistry)
Merge another registry into this one
Schemas from other are added to this registry. If a schema with the
same name already exists, it is NOT overwritten (first registration wins).
Trait Implementations§
Source§impl Clone for TypeSchemaRegistry
impl Clone for TypeSchemaRegistry
Source§fn clone(&self) -> TypeSchemaRegistry
fn clone(&self) -> TypeSchemaRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TypeSchemaRegistry
impl Debug for TypeSchemaRegistry
Source§impl Default for TypeSchemaRegistry
impl Default for TypeSchemaRegistry
Source§fn default() -> TypeSchemaRegistry
fn default() -> TypeSchemaRegistry
Source§impl<'de> Deserialize<'de> for TypeSchemaRegistry
impl<'de> Deserialize<'de> for TypeSchemaRegistry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl SchemaLookup for TypeSchemaRegistry
impl SchemaLookup for TypeSchemaRegistry
Auto Trait Implementations§
impl Freeze for TypeSchemaRegistry
impl RefUnwindSafe for TypeSchemaRegistry
impl Send for TypeSchemaRegistry
impl Sync for TypeSchemaRegistry
impl Unpin for TypeSchemaRegistry
impl UnsafeUnpin for TypeSchemaRegistry
impl UnwindSafe for TypeSchemaRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more