cfgd_core/generate/
mod.rs1pub mod schema;
2pub mod session;
3pub mod validate;
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum SchemaKind {
10 Module,
11 Profile,
12 Config,
13}
14
15impl std::str::FromStr for SchemaKind {
16 type Err = String;
17 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
18 match s.to_lowercase().as_str() {
19 "module" => Ok(Self::Module),
20 "profile" => Ok(Self::Profile),
21 "config" => Ok(Self::Config),
22 _ => Err(format!("unknown schema kind: {}", s)),
23 }
24 }
25}
26
27impl SchemaKind {
28 pub fn as_str(&self) -> &'static str {
29 match self {
30 Self::Module => "Module",
31 Self::Profile => "Profile",
32 Self::Config => "Config",
33 }
34 }
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct PresentYamlRequest {
40 pub content: String,
41 pub kind: String,
42 pub description: String,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(tag = "action")]
48pub enum PresentYamlResponse {
49 #[serde(rename = "accept")]
50 Accept,
51 #[serde(rename = "reject")]
52 Reject,
53 #[serde(rename = "feedback")]
54 Feedback { message: String },
55 #[serde(rename = "stepThrough")]
56 StepThrough,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct ValidationResult {
62 pub valid: bool,
63 pub errors: Vec<String>,
64}