use crate::main_engine::PluginState;
use std::any::{Any, type_name};
use std::time::Duration;
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct ServiceDesc {
pub id: String,
pub req_type: String,
pub res_type: String,
pub doc: String,
pub timeout_hint: Option<Duration>,
}
impl ServiceDesc {
pub fn describe<Req, Res>(id: impl Into<String>, doc: impl Into<String>) -> Self
where
Req: Any + Send + Sync,
Res: Any + Send + Sync,
{
Self {
id: id.into(),
req_type: type_name::<Req>().to_string(),
res_type: type_name::<Res>().to_string(),
doc: doc.into(),
timeout_hint: None,
}
}
pub fn with_timeout(mut self, d: Duration) -> Self {
self.timeout_hint = Some(d);
self
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct ProviderRef {
pub name: String,
pub version: String,
pub state: PluginState,
pub service: ServiceDesc,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PlugNotice {
pub name: String,
pub version: String,
}