quorum_set/quorum/quorum_bridge_impl.rs
1use std::collections::BTreeSet;
2
3use crate::quorum::QuorumBridge;
4
5/// Builds the joint of a joint quorum set and a flat config.
6impl<ID> QuorumBridge<BTreeSet<ID>> for Vec<BTreeSet<ID>>
7where ID: Ord + Clone
8{
9 /// Return the configs of `self` followed by `other`. Return an empty joint when `self` is
10 /// empty: an empty joint has no quorum, so a joint with it has no quorum either.
11 fn joint_with(&self, other: BTreeSet<ID>) -> Self {
12 if self.is_empty() {
13 return vec![];
14 }
15 let mut joint = self.clone();
16 joint.push(other);
17 joint
18 }
19}
20
21/// Builds the joint of the source and target joint configs.
22impl<ID> QuorumBridge<Vec<BTreeSet<ID>>> for Vec<BTreeSet<ID>>
23where ID: Ord + Clone
24{
25 /// Return the configs of `self` followed by the configs of `other`. Return an empty joint
26 /// when `self` or `other` is empty: an empty joint has no quorum, so a joint with it has no
27 /// quorum either.
28 fn joint_with(&self, other: Vec<BTreeSet<ID>>) -> Self {
29 if self.is_empty() || other.is_empty() {
30 return vec![];
31 }
32 let mut joint = self.clone();
33 joint.extend(other);
34 joint
35 }
36}