razeri-plugin-api 0.19.0

Extension traits and registries for Razeri plugins
Documentation
// Copyright (C) 2026 Gabriel Shea
// Licensed under either of the Apache License, Version 2.0 or the MIT
// license, at your option.

//! Unified plugin registry aggregating all sub-registries.
//!
//! [`PluginRegistry`] is the single composition root that holds all
//! extension point registries. It is constructed via [`crate::builder::PluginRegistryBuilder`].

use crate::dialect::PlatformRegistry;
use crate::event::EventRegistry;
use crate::language::LanguageRegistry;
use crate::llm::LlmRegistry;
use crate::model::ModelRegistry;
use crate::storage::StorageRegistry;

/// Aggregates all sub-registries into a single composition root.
///
/// Created by [`crate::builder::PluginRegistryBuilder::build()`].
pub struct PluginRegistry {
    /// Database dialect registry (enum-keyed + string-keyed).
    pub dialects: PlatformRegistry,
    /// Storage provider factory registry (enum-keyed + string-keyed).
    pub storage: StorageRegistry,
    /// LLM provider factory registry (string-keyed).
    pub llm: LlmRegistry,
    /// Model adapter registry ((provider, model) keyed).
    pub models: ModelRegistry,
    /// Language renderer factory registry (string-keyed).
    pub language: LanguageRegistry,
    /// Event sink registry (fan-out to all sinks).
    pub events: EventRegistry,
}

#[cfg(test)]
mod tests {
    use crate::builder::PluginRegistryBuilder;

    #[test]
    fn empty_builder_creates_empty_registry() {
        let registry = PluginRegistryBuilder::new().build();
        assert_eq!(registry.dialects.list().len(), 0);
        assert_eq!(registry.llm.list().len(), 0);
        assert!(registry.events.is_empty());
    }
}