swh_graph/views/spy/
label_names.rs1use super::*;
9
10impl<
11 G: SwhGraphWithProperties<LabelNames: properties::LabelNames>,
12 MAPS: properties::MaybeMaps,
13 TIMESTAMPS: properties::MaybeTimestamps,
14 PERSONS: properties::MaybePersons,
15 CONTENTS: properties::MaybeContents,
16 STRINGS: properties::MaybeStrings,
17 > GraphSpy<G, MAPS, TIMESTAMPS, PERSONS, CONTENTS, STRINGS, properties::NoLabelNames>
18{
19 pub fn with_label_names(
20 self,
21 ) -> GraphSpy<G, MAPS, TIMESTAMPS, PERSONS, CONTENTS, STRINGS, LabelNamesSpy<G>> {
22 let GraphSpy {
23 properties:
24 properties::SwhGraphProperties {
25 path,
26 num_nodes,
27 maps,
28 timestamps,
29 persons,
30 contents,
31 strings,
32 label_names: properties::NoLabelNames,
33 label_names_are_in_base64_order,
34 },
35 inner,
36 history,
37 } = self;
38
39 GraphSpy {
40 properties: properties::SwhGraphProperties {
41 path,
42 num_nodes,
43 maps,
44 timestamps,
45 persons,
46 contents,
47 strings,
48 label_names: LabelNamesSpy {
49 graph: Arc::clone(&inner),
50 history: Arc::clone(&history),
51 },
52 label_names_are_in_base64_order,
53 },
54 inner,
55 history,
56 }
57 }
58}
59
60pub struct LabelNamesSpy<G: SwhGraphWithProperties<LabelNames: properties::LabelNames>> {
61 graph: Arc<GraphSpyInner<G>>,
62 history: Arc<Mutex<Vec<GraphAccessRecord>>>,
63}
64
65impl<G: SwhGraphWithProperties<LabelNames: properties::LabelNames>> properties::LabelNames
66 for LabelNamesSpy<G>
67{
68 type LabelNames<'a>
69 = <<G as SwhGraphWithProperties>::LabelNames as properties::LabelNames>::LabelNames<'a>
70 where
71 Self: 'a;
72
73 fn label_names(&self) -> Self::LabelNames<'_> {
74 self.history
75 .lock()
76 .unwrap()
77 .push(GraphAccessRecord::Property(PropertyAccess::LabelNames));
78 self.graph.graph.properties().label_names.label_names()
79 }
80}