siera_agent/modules/
feature.rs

1use async_trait::async_trait;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4
5use crate::error::Result;
6
7/// Repsonse of the cloudagent for discovering features
8#[derive(Debug, Serialize, Deserialize)]
9pub struct DiscoverFeaturesResponse {
10    /// The query used for the request
11    pub query_msg: Value,
12
13    /// Which features are disclosed
14    pub disclose: Disclose,
15}
16
17/// A feature which is in the `Disclosed` structure
18#[derive(Debug, Serialize, Deserialize)]
19pub struct Disclose {
20    /// The type of the request
21    #[serde(rename = "@type")]
22    pub type_field: String,
23
24    /// The id of the request
25    #[serde(rename = "@id")]
26    pub id: String,
27
28    /// All the supported protocols of the cloudagent
29    pub protocols: Vec<Protocol>,
30}
31
32/// A protocol
33#[derive(Debug, Serialize, Deserialize)]
34pub struct Protocol {
35    /// Protocol id
36    pub pid: String,
37}
38
39/// Generic cloudagent feature module
40#[async_trait]
41pub trait FeatureModule {
42    /// Requests all the features from the cloudagent
43    async fn discover_features(&self) -> Result<DiscoverFeaturesResponse>;
44}