//! Registry data types.

use std::collections::BTreeMap;

use aqc_file_engine_core::Engine;
use shakrs_core::{Adapter, Policy};

/// Holds the registered plugins for one run, each keyed by its `id()`.
pub struct Registry {
    /// Registered policies, keyed by policy id.
    pub(crate) policies: BTreeMap<&'static str, Box<dyn Policy>>,
    /// Registered adapters, keyed by adapter id.
    pub(crate) adapters: BTreeMap<&'static str, Box<dyn Adapter>>,
    /// Registered engines, keyed by engine id.
    pub(crate) engines: BTreeMap<&'static str, Box<dyn Engine>>,
}

/// Why building the registry failed.
#[derive(Debug, Clone)]
#[expect(
    clippy::module_name_repetitions,
    reason = "RegistryError is the registry constructor's error; the name reads at call sites."
)]
pub enum RegistryError {
    /// Two plugins in one stage share an id.
    DuplicateId { stage: &'static str, id: String },
    /// A plugin reported an empty id.
    EmptyId { stage: &'static str },
    /// A stage has no registered plugins.
    EmptyStage { stage: &'static str },
}
