wenlan_types/
lint_group.rs1use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
5#[serde(rename_all = "snake_case")]
6pub enum LintCheckGroup {
7 Identity,
8 KnowledgeGraph,
9 Memories,
10 Operations,
11 Pages,
12 Runtime,
13 Serving,
14}
15
16impl LintCheckGroup {
17 pub const ALL: [Self; 7] = [
18 Self::Identity,
19 Self::KnowledgeGraph,
20 Self::Memories,
21 Self::Operations,
22 Self::Pages,
23 Self::Runtime,
24 Self::Serving,
25 ];
26
27 pub const fn as_str(self) -> &'static str {
28 match self {
29 Self::Identity => "identity",
30 Self::KnowledgeGraph => "knowledge_graph",
31 Self::Memories => "memories",
32 Self::Operations => "operations",
33 Self::Pages => "pages",
34 Self::Runtime => "runtime",
35 Self::Serving => "serving",
36 }
37 }
38
39 pub fn for_check_id(check_id: &str) -> Option<Self> {
40 let owner = check_id
41 .split_once('.')
42 .map_or(check_id, |(owner, _)| owner);
43 match owner {
44 "identity" => Some(Self::Identity),
45 "entities" | "kg" | "memory_entities" | "observations" | "relations" => {
46 Some(Self::KnowledgeGraph)
47 }
48 "memories" => Some(Self::Memories),
49 "operations" => Some(Self::Operations),
50 "pages" => Some(Self::Pages),
51 "runtime" => Some(Self::Runtime),
52 "serving" => Some(Self::Serving),
53 _ => None,
54 }
55 }
56}