pub trait TypeRegistry: Send + Sync {
// Required methods
fn get(&self, id: &TypeId) -> Option<&TypeDescriptor>;
fn for_collection(&self, collection: &str) -> Option<&TypeDescriptor>;
fn iter(&self) -> Box<dyn Iterator<Item = &TypeDescriptor> + '_>;
}Expand description
Trait for type registries. Consumers can build their own, or use the
builtin one for peat-schema’s known types.
Send + Sync so the registry can be shared across threads (e.g.
embedded inside a long-lived consumer process).
Required Methods§
Sourcefn get(&self, id: &TypeId) -> Option<&TypeDescriptor>
fn get(&self, id: &TypeId) -> Option<&TypeDescriptor>
Look up by canonical identifier.
Sourcefn for_collection(&self, collection: &str) -> Option<&TypeDescriptor>
fn for_collection(&self, collection: &str) -> Option<&TypeDescriptor>
Look up by conventional collection name (the convention each
TypeDescriptor carries in its canonical_collection field).
Sourcefn iter(&self) -> Box<dyn Iterator<Item = &TypeDescriptor> + '_>
fn iter(&self) -> Box<dyn Iterator<Item = &TypeDescriptor> + '_>
Iterate over all registered descriptors.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".