spin_factors/
runtime_config.rs

1pub mod toml;
2
3use crate::Factor;
4
5/// The source of runtime configuration for a particular [`Factor`].
6pub trait FactorRuntimeConfigSource<F: Factor> {
7    /// Get the runtime configuration for the factor.
8    fn get_runtime_config(&mut self) -> anyhow::Result<Option<F::RuntimeConfig>>;
9}
10
11impl<F: Factor> FactorRuntimeConfigSource<F> for () {
12    fn get_runtime_config(&mut self) -> anyhow::Result<Option<<F as Factor>::RuntimeConfig>> {
13        Ok(None)
14    }
15}
16
17/// Run some finalization logic on a [`FactorRuntimeConfigSource`].
18pub trait RuntimeConfigSourceFinalizer {
19    /// Finalize the runtime config source.
20    fn finalize(&mut self) -> anyhow::Result<()>;
21}
22
23impl RuntimeConfigSourceFinalizer for () {
24    fn finalize(&mut self) -> anyhow::Result<()> {
25        Ok(())
26    }
27}