From c14bf4248550f9ad8f9baac1e9083dc59b6bc5b3 Mon Sep 17 00:00:00 2001 From: Arnaud Mimart <33665250+amimart@users.noreply.github.com> Date: Fri, 2 Feb 2024 10:59:05 +0100 Subject: [PATCH] fix(rdf): make quad pattern iter skip work --- contracts/okp4-dataverse/src/credential/proof.rs | 12 ++++++++---- packages/okp4-rdf/src/dataset.rs | 7 ++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/contracts/okp4-dataverse/src/credential/proof.rs b/contracts/okp4-dataverse/src/credential/proof.rs index 93b1380a..a8396598 100644 --- a/contracts/okp4-dataverse/src/credential/proof.rs +++ b/contracts/okp4-dataverse/src/credential/proof.rs @@ -220,11 +220,15 @@ impl<'a> TryFrom<(&'a Dataset<'a>, GraphName<'a>)> for Ed25519Signature2020Proof value: p_value, options: Dataset::new( dataset + .match_pattern(None, None, None, Some(Some(proof_graph))) .skip_pattern( - None, - Some(PROOF_RDF_PROOF_VALUE), - None, - Some(Some(proof_graph)), + ( + None, + Some(PROOF_RDF_PROOF_VALUE), + None, + Some(Some(proof_graph)), + ) + .into(), ) .map(|quad| *quad) .collect(), diff --git a/packages/okp4-rdf/src/dataset.rs b/packages/okp4-rdf/src/dataset.rs index ea5f00f2..eb520c11 100644 --- a/packages/okp4-rdf/src/dataset.rs +++ b/packages/okp4-rdf/src/dataset.rs @@ -102,10 +102,6 @@ impl QuadPattern<'_> { .map(|o| o == quad.graph_name) .unwrap_or_else(|| true) } - - pub fn skip_pattern<'a>(self, quad: &'a Quad<'a>) -> bool { - !self.match_pattern(quad) - } } pub trait QuadIterator<'a>: Iterator> { @@ -214,7 +210,8 @@ where QuadPatternFilterKind::Skip => self .patterns .iter() - .fold(true, |v, p| v || p.skip_pattern(quad)), + .find(|p| p.match_pattern(quad)) + .is_none(), }) } }