routee_compass/plugin/input/input_plugin_builder.rs
1use crate::plugin::input::InputPlugin;
2use routee_compass_core::config::CompassConfigurationError;
3use std::sync::Arc;
4
5/// A [`InputPluginBuilder`] takes a JSON object describing the configuration of an
6/// input plugin and builds a [InputPlugin].
7///
8/// A [`InputPluginBuilder`] instance should be an empty struct that implements
9/// this trait.
10///
11/// [InputPlugin]: compass_app::plugin::input::input_plugin::InputPlugin
12pub trait InputPluginBuilder {
13 /// Builds a [InputPlugin] from JSON configuration.
14 ///
15 /// # Arguments
16 ///
17 /// * `parameters` - the contents of an element in the "input_plugin" array TOML config section
18 ///
19 /// # Returns
20 ///
21 /// A [InputPlugin] designed to persist the duration of the CompassApp.
22 ///
23 /// [InputPlugin]: compass_app::plugin::input::input_plugin::InputPlugin
24 fn build(
25 &self,
26 parameters: &serde_json::Value,
27 ) -> Result<Arc<dyn InputPlugin>, CompassConfigurationError>;
28}