Skip to main content

subspace_shell/registry/
configuration.rs

1//! Provider-owned inputs, compared without serializing or exposing credentials.
2
3use super::BoardRegistration;
4use std::{any::Any, sync::Arc};
5
6#[derive(Clone)]
7pub struct BoardConfiguration {
8    value: Arc<dyn Any + Send + Sync>,
9    equal: fn(&dyn Any, &dyn Any) -> bool,
10}
11
12impl PartialEq for BoardConfiguration {
13    fn eq(&self, other: &Self) -> bool {
14        (self.equal)(self.value.as_ref(), other.value.as_ref())
15    }
16}
17
18// qual:allow(coupling, deh) reason: "Configured providers own different concrete input types; this equality boundary uses checked Any downcasts and never formats credentials."
19fn equal<T: PartialEq + 'static>(left: &dyn Any, right: &dyn Any) -> bool {
20    match (left.downcast_ref::<T>(), right.downcast_ref::<T>()) {
21        (Some(left), Some(right)) => left == right,
22        _ => false,
23    }
24}
25
26impl BoardRegistration {
27    /// Captures configured inputs so unchanged instances survive live reloads.
28    // qual:api
29    pub fn with_configuration<T: PartialEq + Send + Sync + 'static>(mut self, value: T) -> Self {
30        self.configuration = Some(BoardConfiguration {
31            value: Arc::new(value),
32            equal: equal::<T>,
33        });
34        self
35    }
36}