use std::collections::HashMap; // use bincode::{Decode, Encode}; // use serde::{Deserialize, Serialize}; use bincode::{Decode, Encode}; use crate::{ModuleError, ModuleRuntime}; // /// Payload config that is instantiated // #[derive(Serialize, Deserialize)] // pub struct Config { // pub id: String, // pub key: String, // pub components: Vec, // } pub struct PayloadConfig { pub id: &'static str, pub components: Vec, pub runtime_config: Vec, } #[derive(Debug, Clone, Encode, Decode)] pub struct RuntimeConfig { pub parent_component: String, pub name: String, pub config: HashMap, } #[derive(Clone)] pub struct NamedComponent { pub name: &'static str, // + Sync + Sync + Sync + Sync + Sync + Sync + Sync + Sync pub get_interface: &'static (dyn Fn() -> Option<&'static (dyn InterfaceWrapper + Sync)> + Sync), pub start_runtime: &'static ( dyn Fn(&'static RuntimeConfig) -> Result, ModuleError> + Sync ), } /// Trait that wraps the get_interface() function inside of components pub trait InterfaceWrapper: Send + Sync { fn get_interface(&self) -> Option where Self: Sized; } // impl InterfaceWrapper for T { // default fn get_interface() -> Option // where // Self: Sized, // { // None // } // }