siera_agent/modules/
schema.rs1use crate::error::Result;
2use async_trait::async_trait;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Deserialize, Serialize, Default)]
7pub struct Schema {
8 pub ver: String,
10
11 pub id: String,
13
14 pub name: String,
16
17 pub version: String,
19
20 #[serde(rename(deserialize = "attrNames"))]
22 pub attr_names: Vec<String>,
23
24 #[serde(rename(deserialize = "seqNo"))]
26 pub seq_no: Option<i32>,
27}
28
29#[derive(Debug, Serialize)]
31pub struct SchemaCreateOptions {
32 pub name: String,
34
35 pub version: String,
37
38 pub attributes: Vec<String>,
40}
41
42#[derive(Debug, Deserialize, Serialize)]
45pub struct SchemasGetAllResponse {
46 pub schema_ids: Vec<String>,
48}
49
50#[async_trait]
52pub trait SchemaModule {
53 async fn create(&self, options: SchemaCreateOptions) -> Result<Schema>;
55
56 async fn get_by_id(&self, id: String) -> Result<Schema>;
58
59 async fn get_all(&self) -> Result<SchemasGetAllResponse>;
61}