Skip to main content

TypeRegistry

Trait TypeRegistry 

Source
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§

Source

fn get(&self, id: &TypeId) -> Option<&TypeDescriptor>

Look up by canonical identifier.

Source

fn for_collection(&self, collection: &str) -> Option<&TypeDescriptor>

Look up by conventional collection name (the convention each TypeDescriptor carries in its canonical_collection field).

Source

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".

Implementors§