1#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct Honesty {
8 pub vocabulary: [&'static str; 3],
9 pub this_emit: &'static str,
10 pub note: &'static str,
11}
12
13impl Honesty {
14 pub fn presence_index() -> Self {
16 Self {
17 vocabulary: ["Present", "Live", "Planned"],
18 this_emit: "Present",
19 note: "Indexer found these in the tree. Presence is not Live. No Live/Planned stamps in MVP. No held/not-yet amber theatre.",
20 }
21 }
22}
23
24#[derive(Debug, Clone, PartialEq, Eq)]
25pub struct Project {
26 pub root: String,
27 pub tip_sha: String,
28 pub branch: String,
29 pub dirty: bool,
30 pub indexed_at_unix: u64,
31}
32
33#[derive(Debug, Clone, PartialEq, Eq)]
34pub struct FileNode {
35 pub path: String,
36 pub lang: &'static str,
37}
38
39#[derive(Debug, Clone, PartialEq, Eq)]
40pub struct CrateNode {
41 pub name: String,
42 pub manifest: String,
43}
44
45#[derive(Debug, Clone, PartialEq, Eq)]
46pub struct FamilyNode {
47 pub name: String,
48 pub member_count: u32,
49}
50
51#[derive(Debug, Clone, PartialEq, Eq)]
52pub struct DocCite {
53 pub about: String,
54 pub doc_path: String,
55 pub kind: &'static str,
56}
57
58#[derive(Debug, Clone, PartialEq, Eq)]
59pub struct Sources {
60 pub all_bound: String,
61 pub catalog: Option<String>,
62}
63
64#[derive(Debug, Clone, PartialEq, Eq)]
65pub struct WorkGraph {
66 pub honesty: Honesty,
67 pub project: Project,
68 pub files: Vec<FileNode>,
69 pub crates: Vec<CrateNode>,
70 pub invoke_ids: Vec<String>,
71 pub catalog_ids: Vec<String>,
72 pub catalog_present: bool,
73 pub families: Vec<FamilyNode>,
74 pub doc_pages: Vec<String>,
75 pub doc_cites: Vec<DocCite>,
76 pub sources: Sources,
77}
78
79impl WorkGraph {
80 pub fn catalog_only_ids(&self) -> Vec<&str> {
82 let bound: std::collections::BTreeSet<&str> =
83 self.invoke_ids.iter().map(String::as_str).collect();
84 self.catalog_ids
85 .iter()
86 .map(String::as_str)
87 .filter(|id| !bound.contains(id))
88 .collect()
89 }
90
91 pub fn bound_missing_from_catalog(&self) -> Vec<&str> {
93 if !self.catalog_present {
94 return Vec::new();
95 }
96 let catalog: std::collections::BTreeSet<&str> =
97 self.catalog_ids.iter().map(String::as_str).collect();
98 self.invoke_ids
99 .iter()
100 .map(String::as_str)
101 .filter(|id| !catalog.contains(id))
102 .collect()
103 }
104}