code_repo_wiki/model/
node.rs1use petgraph::stable_graph::NodeIndex;
2use serde::{Deserialize, Serialize};
3
4pub type NodeId = NodeIndex<u32>;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct CodeNode {
10 pub id: NodeId,
12 pub kind: NodeKind,
14 pub name: String,
16 pub file_path: Option<String>,
18 pub line_range: Option<(usize, usize)>,
20 pub doc_comment: Option<String>,
22 pub signature: Option<String>,
24 #[serde(default)]
28 pub visibility: Option<String>,
29 pub module_path: Vec<String>,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
35pub enum NodeKind {
36 Project,
38 Module,
40 File,
42 Struct,
44 Enum,
46 Function,
48 Trait,
50 Impl,
52 Type,
54 Constant,
56 Variable,
58 Interface,
60 Class,
62 Macro,
64}
65
66impl NodeKind {
67 pub fn as_str(&self) -> &'static str {
68 match self {
69 NodeKind::Project => "project",
70 NodeKind::Module => "module",
71 NodeKind::File => "file",
72 NodeKind::Struct => "struct",
73 NodeKind::Enum => "enum",
74 NodeKind::Function => "function",
75 NodeKind::Trait => "trait",
76 NodeKind::Impl => "impl",
77 NodeKind::Type => "type",
78 NodeKind::Constant => "constant",
79 NodeKind::Variable => "variable",
80 NodeKind::Interface => "interface",
81 NodeKind::Class => "class",
82 NodeKind::Macro => "macro",
83 }
84 }
85}