1use crate::main_engine::PluginState;
4use std::any::{Any, type_name};
5use std::time::Duration;
6
7#[derive(Clone, Debug, PartialEq, Eq, Default)]
9pub struct ServiceDesc {
10 pub id: String,
12 pub req_type: String,
14 pub res_type: String,
16 pub doc: String,
18 pub timeout_hint: Option<Duration>,
20}
21
22impl ServiceDesc {
23 pub fn describe<Req, Res>(id: impl Into<String>, doc: impl Into<String>) -> Self
25 where
26 Req: Any + Send + Sync,
27 Res: Any + Send + Sync,
28 {
29 Self {
30 id: id.into(),
31 req_type: type_name::<Req>().to_string(),
32 res_type: type_name::<Res>().to_string(),
33 doc: doc.into(),
34 timeout_hint: None,
35 }
36 }
37
38 pub fn with_timeout(mut self, d: Duration) -> Self {
40 self.timeout_hint = Some(d);
41 self
42 }
43}
44
45#[derive(Clone, Debug, PartialEq)]
47pub struct ProviderRef {
48 pub name: String,
50 pub version: String,
52 pub state: PluginState,
54 pub service: ServiceDesc,
56}
57
58#[derive(Clone, Debug, PartialEq, Eq)]
61pub struct PlugNotice {
62 pub name: String,
63 pub version: String,
64}