|
19 | 19 | // See the License for the specific language governing permissions and
|
20 | 20 | // limitations under the License.
|
21 | 21 |
|
22 |
| -use std::collections::{BTreeSet, HashSet}; |
| 22 | +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; |
23 | 23 | use std::ops::Deref;
|
24 | 24 |
|
25 | 25 | use rgb::{AssignmentWitness, XOutpoint};
|
@@ -99,6 +99,20 @@ impl OutpointFilter for BTreeSet<XOutpoint> {
|
99 | 99 | }
|
100 | 100 | }
|
101 | 101 |
|
| 102 | +impl<V> OutpointFilter for HashMap<XOutpoint, V> { |
| 103 | + fn include_outpoint(&self, outpoint: impl Into<XOutpoint>) -> bool { |
| 104 | + let outpoint = outpoint.into(); |
| 105 | + self.keys().any(|o| *o == outpoint) |
| 106 | + } |
| 107 | +} |
| 108 | + |
| 109 | +impl<V> OutpointFilter for BTreeMap<XOutpoint, V> { |
| 110 | + fn include_outpoint(&self, outpoint: impl Into<XOutpoint>) -> bool { |
| 111 | + let outpoint = outpoint.into(); |
| 112 | + self.keys().any(|o| *o == outpoint) |
| 113 | + } |
| 114 | +} |
| 115 | + |
102 | 116 | // WitnessFilter
|
103 | 117 |
|
104 | 118 | impl WitnessFilter for FilterIncludeAll {
|
@@ -166,3 +180,17 @@ impl WitnessFilter for BTreeSet<AssignmentWitness> {
|
166 | 180 | self.contains(&witness.into())
|
167 | 181 | }
|
168 | 182 | }
|
| 183 | + |
| 184 | +impl<V> WitnessFilter for HashMap<AssignmentWitness, V> { |
| 185 | + fn include_witness(&self, witness: impl Into<AssignmentWitness>) -> bool { |
| 186 | + let witness = witness.into(); |
| 187 | + self.keys().any(|w| *w == witness) |
| 188 | + } |
| 189 | +} |
| 190 | + |
| 191 | +impl<V> WitnessFilter for BTreeMap<AssignmentWitness, V> { |
| 192 | + fn include_witness(&self, witness: impl Into<AssignmentWitness>) -> bool { |
| 193 | + let witness = witness.into(); |
| 194 | + self.keys().any(|w| *w == witness) |
| 195 | + } |
| 196 | +} |
0 commit comments