From 582a079f1cccc07bd74432ceb55da09e698da2d0 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 11 Dec 2020 11:01:27 +0100 Subject: openpgp: Make Cert::CertParser Send and Sync. - See #615. --- openpgp/src/cert.rs | 2 +- openpgp/src/cert/parser/mod.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs index bb2970fc..78dad9b1 100644 --- a/openpgp/src/cert.rs +++ b/openpgp/src/cert.rs @@ -1384,7 +1384,7 @@ impl Cert { /// # Ok(()) /// # } /// ``` - pub fn from_packets(p: impl Iterator) -> Result { + pub fn from_packets(p: impl Iterator + Send + Sync) -> Result { let mut i = parser::CertParser::from_iter(p); if let Some(cert_result) = i.next() { if i.next().is_some() { diff --git a/openpgp/src/cert/parser/mod.rs b/openpgp/src/cert/parser/mod.rs index 48b340c9..ca320cf9 100644 --- a/openpgp/src/cert/parser/mod.rs +++ b/openpgp/src/cert/parser/mod.rs @@ -507,11 +507,12 @@ impl CertValidator { /// ``` pub struct CertParser<'a> { - source: Option> + 'a>>, + source: Option> + 'a + Send + Sync>>, packets: Vec, saw_error: bool, - filter: Vec bool + 'a>>, + filter: Vec bool + 'a>>, } +assert_send_and_sync!(CertParser<'_>); impl<'a> Default for CertParser<'a> { fn default() -> Self { @@ -682,7 +683,8 @@ impl<'a> CertParser<'a> { /// ``` pub fn from_iter(iter: I) -> Self where I: 'a + IntoIterator, - J: 'a + Into> + J: 'a + Into>, + ::IntoIter: Send + Sync, { let mut parser : Self = Default::default(); parser.source = Some(Box::new(iter.into_iter().map(Into::into))); @@ -759,7 +761,7 @@ impl<'a> CertParser<'a> { /// # } /// ``` pub fn unvalidated_cert_filter(mut self, filter: F) -> Self - where F: Fn(&Cert, bool) -> bool + where F: Send + Sync + Fn(&Cert, bool) -> bool { self.filter.push(Box::new(filter)); self -- cgit v1.2.3