1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
use crate*;
use HashSet;
/// Compares two `ConfigObjectMap` instances and returns the names of objects that are exclusive to
/// each map, as well as the names of objects that are common to both maps.
///
/// # Type Parameters
/// * `T` - The type of the objects stored in the maps. Must implement the `ConfigObject` trait.
///
/// # Arguments
/// * `a` - The first `ConfigObjectMap` to compare.
/// * `b` - The second `ConfigObjectMap` to compare.
///
/// # Returns
/// A tuple containing the following:
/// * `a_exclusive` - A `HashSet<String>` containing the names of objects that are in `a` but not `b`.
/// * `b_exclusive` - A `HashSet<String>` containing the names of objects that are in `b` but not `a`.
/// * `common` - A `HashSet<String>` containing the names of objects that are in both `a` and `b`.
///
/// # Example
/// ```rust
/// use opsview::prelude::*;
/// use opsview::config::{Hashtag, compare_config_object_maps};
///
/// let mut a = ConfigObjectMap::<Hashtag>::new();
/// let mut b = ConfigObjectMap::<Hashtag>::new();
///
/// let hashtag1 = Hashtag::minimal("MyHashtag1").unwrap();
/// let hashtag2 = Hashtag::minimal("MyHashtag2").unwrap();
/// let hashtag3 = Hashtag::minimal("MyHashtag3").unwrap();
///
/// a.add(hashtag1.clone());
/// a.add(hashtag2.clone());
///
/// b.add(hashtag2.clone());
/// b.add(hashtag3.clone());
///
/// let (a_exclusive, b_exclusive, common) = compare_config_object_maps(&a, &b);
///
/// assert_eq!(a_exclusive.len(), 1);
/// assert_eq!(b_exclusive.len(), 1);
/// assert_eq!(common.len(), 1);
/// assert!(a_exclusive.is_disjoint(&b_exclusive));
/// assert!(a_exclusive.contains(&hashtag1.name));
/// assert!(b_exclusive.contains(&hashtag3.name));
/// assert!(common.contains(&hashtag2.name));
/// ```
/// Compares two `ConfigRefMap` instances and returns the names of objects that are exclusive to
/// each map, as well as the names of objects that are common to both maps.
///
/// # Type Parameters
/// * `T` - The type of the objects stored in the maps. Must implement the `ConfigRef` trait.
///
/// # Arguments
/// * `a` - The first `ConfigRefMap` to compare.
/// * `b` - The second `ConfigRefMap` to compare.
///
/// # Returns
/// A tuple containing the following:
/// * `a_exclusive` - A `HashSet<String>` containing the names of objects that are in `a` but not `b`.
/// * `b_exclusive` - A `HashSet<String>` containing the names of objects that are in `b` but not `a`.
/// * `common` - A `HashSet<String>` containing the names of objects that are in both `a` and `b`.
///
/// # Example
/// ```rust
/// use opsview::prelude::*;
/// use opsview::config::{Hashtag, HashtagRef, compare_config_ref_maps};
///
/// let mut a_objs = ConfigObjectMap::<Hashtag>::new();
/// let mut b_objs = ConfigObjectMap::<Hashtag>::new();
///
/// let hashtag1 = Hashtag::minimal("MyHashtag1").unwrap();
/// let hashtag2 = Hashtag::minimal("MyHashtag2").unwrap();
/// let hashtag3 = Hashtag::minimal("MyHashtag3").unwrap();
///
/// a_objs.add(hashtag1.clone());
/// a_objs.add(hashtag2.clone());
/// let a_refs: ConfigRefMap<HashtagRef> = ref_map_from(&a_objs);
///
/// b_objs.add(hashtag2.clone());
/// b_objs.add(hashtag3.clone());
/// let b_refs: ConfigRefMap<HashtagRef> = ref_map_from(&b_objs);
///
/// let (a_exclusive, b_exclusive, common) = compare_config_ref_maps(&a_refs, &b_refs);
///
/// assert_eq!(a_exclusive.len(), 1);
/// assert_eq!(b_exclusive.len(), 1);
/// assert_eq!(common.len(), 1);
/// assert!(a_exclusive.is_disjoint(&b_exclusive));
/// assert!(a_exclusive.contains(&hashtag1.name));
/// assert!(b_exclusive.contains(&hashtag3.name));
/// assert!(common.contains(&hashtag2.name));
/// ```