archidoc_types/
module_doc.rs1use serde::{Deserialize, Serialize};
2use std::fmt;
3
4use crate::annotation::{HealthStatus, PatternStatus};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
8#[serde(rename_all = "lowercase")]
9pub enum C4Level {
10 Container,
11 Component,
12 Unknown,
13}
14
15impl fmt::Display for C4Level {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 match self {
18 Self::Container => write!(f, "container"),
19 Self::Component => write!(f, "component"),
20 Self::Unknown => write!(f, "unknown"),
21 }
22 }
23}
24
25impl C4Level {
26 pub fn parse(s: &str) -> Self {
27 match s.trim().to_lowercase().as_str() {
28 "container" => Self::Container,
29 "component" => Self::Component,
30 _ => Self::Unknown,
31 }
32 }
33}
34
35#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
37pub struct Relationship {
38 pub target: String,
39 pub label: String,
40 pub protocol: String,
41}
42
43#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
45pub struct FileEntry {
46 pub name: String,
47 pub pattern: String,
48 pub pattern_status: PatternStatus,
49 pub purpose: String,
50 pub health: HealthStatus,
51}
52
53#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
58pub struct ModuleDoc {
59 pub module_path: String,
60 pub content: String,
61 pub source_file: String,
62 pub c4_level: C4Level,
63 pub pattern: String,
64 pub pattern_status: PatternStatus,
65 pub description: String,
66 pub parent_container: Option<String>,
67 pub relationships: Vec<Relationship>,
68 pub files: Vec<FileEntry>,
69}