Skip to main content

routee_compass/plugin/output/default/summary/
builder.rs

1use super::plugin::SummaryOutputPlugin;
2use crate::{
3    app::compass::CompassComponentError,
4    plugin::{
5        output::{default::summary::SummaryConfig, OutputPlugin, OutputPluginBuilder},
6        PluginError,
7    },
8};
9use std::sync::Arc;
10
11pub struct SummaryOutputPluginBuilder {}
12
13impl OutputPluginBuilder for SummaryOutputPluginBuilder {
14    fn build(
15        &self,
16        parameters: &serde_json::Value,
17    ) -> Result<Arc<dyn OutputPlugin>, CompassComponentError> {
18        let conf: SummaryConfig = serde_json::from_value(parameters.clone()).map_err(|e| {
19            PluginError::BuildFailed(format!("failure reading summary output plugin config: {e}"))
20        })?;
21        Ok(Arc::new(SummaryOutputPlugin::new(conf)))
22    }
23}