summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2020-12-11 11:01:27 +0100
committerAzul <azul@riseup.net>2020-12-11 13:44:37 +0100
commit582a079f1cccc07bd74432ceb55da09e698da2d0 (patch)
tree768ff87d0985eb9460b036b732f3a73fb916068b
parent7176d5746beb8835a1a09e9c3504f7bc8d0da6b3 (diff)
openpgp: Make Cert::CertParser Send and Sync.
- See #615.
-rw-r--r--openpgp/src/cert.rs2
-rw-r--r--openpgp/src/cert/parser/mod.rs10
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<Item=Packet>) -> Result<Self> {
+ pub fn from_packets(p: impl Iterator<Item=Packet> + Send + Sync) -> Result<Self> {
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<Box<dyn Iterator<Item=Result<Packet>> + 'a>>,
+ source: Option<Box<dyn Iterator<Item=Result<Packet>> + 'a + Send + Sync>>,
packets: Vec<Packet>,
saw_error: bool,
- filter: Vec<Box<dyn Fn(&Cert, bool) -> bool + 'a>>,
+ filter: Vec<Box<dyn Send + Sync + Fn(&Cert, bool) -> 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<I, J>(iter: I) -> Self
where I: 'a + IntoIterator<Item=J>,
- J: 'a + Into<Result<Packet>>
+ J: 'a + Into<Result<Packet>>,
+ <I as IntoIterator>::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<F: 'a>(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