spin_factors/
runtime_config.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
pub mod toml;

use crate::Factor;

/// The source of runtime configuration for a particular [`Factor`].
pub trait FactorRuntimeConfigSource<F: Factor> {
    /// Get the runtime configuration for the factor.
    fn get_runtime_config(&mut self) -> anyhow::Result<Option<F::RuntimeConfig>>;
}

impl<F: Factor> FactorRuntimeConfigSource<F> for () {
    fn get_runtime_config(&mut self) -> anyhow::Result<Option<<F as Factor>::RuntimeConfig>> {
        Ok(None)
    }
}

/// Run some finalization logic on a [`FactorRuntimeConfigSource`].
pub trait RuntimeConfigSourceFinalizer {
    /// Finalize the runtime config source.
    fn finalize(&mut self) -> anyhow::Result<()>;
}

impl RuntimeConfigSourceFinalizer for () {
    fn finalize(&mut self) -> anyhow::Result<()> {
        Ok(())
    }
}