From 15429e90e6ec1ff1401500f592e8698a89b8cceb Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 8 Dec 2020 09:25:51 +0100 Subject: openpgp: Add assert_send_and_sync! for more types. - With !928 merged more types are `Send` and `Sync` now. - See #627. --- openpgp/src/armor.rs | 1 - openpgp/src/crypto/symmetric.rs | 2 ++ openpgp/src/parse.rs | 1 + openpgp/src/serialize/stream.rs | 15 +++++++-------- openpgp/src/serialize/stream/padding.rs | 1 + 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs index 2852ac72..0c434070 100644 --- a/openpgp/src/armor.rs +++ b/openpgp/src/armor.rs @@ -173,7 +173,6 @@ pub struct Writer { header: Vec, dirty: bool, } - assert_send_and_sync!{Writer, W: Write} impl Writer { diff --git a/openpgp/src/crypto/symmetric.rs b/openpgp/src/crypto/symmetric.rs index d442a684..a364ba53 100644 --- a/openpgp/src/crypto/symmetric.rs +++ b/openpgp/src/crypto/symmetric.rs @@ -51,6 +51,7 @@ pub struct Decryptor { // Up to a block of unread data. buffer: Vec, } +assert_send_and_sync!{Decryptor, R: io::Read} impl Decryptor { /// Instantiate a new symmetric decryptor. `reader` is the source @@ -317,6 +318,7 @@ pub struct Encryptor { // A place to write encrypted data into. scratch: Vec, } +assert_send_and_sync!{Encryptor, W: io::Write} impl Encryptor { /// Instantiate a new symmetric encryptor. diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs index d25d4a73..1d25ca38 100644 --- a/openpgp/src/parse.rs +++ b/openpgp/src/parse.rs @@ -707,6 +707,7 @@ pub struct Cookie { /// encounters a fake EOF at the level it is popping to. fake_eof: bool, } +assert_send_and_sync!{Cookie} /// Contains hashes for consecutive one pass signature packets ending /// in one with the last flag set. diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs index f77dfee0..0948a242 100644 --- a/openpgp/src/serialize/stream.rs +++ b/openpgp/src/serialize/stream.rs @@ -205,6 +205,7 @@ impl Default for Cookie { /// [`Message::finalize`]: #method.finalize #[derive(Debug)] pub struct Message<'a>(writer::BoxStack<'a, Cookie>); +assert_send_and_sync!{Message<'_>} impl<'a> Message<'a> { /// Starts streaming an OpenPGP message. @@ -344,6 +345,7 @@ pub struct Armorer<'a> { headers: Vec<(String, String)>, inner: Message<'a>, } +assert_send_and_sync!{Armorer<'_>} impl<'a> Armorer<'a> { /// Creates a new armoring filter. @@ -533,6 +535,7 @@ impl<'a> fmt::Debug for Armorer<'a> { pub struct ArbitraryWriter<'a> { inner: writer::BoxStack<'a, Cookie>, } +assert_send_and_sync!{ArbitraryWriter<'_>} impl<'a> ArbitraryWriter<'a> { /// Creates a new writer with the given tag. @@ -643,6 +646,7 @@ pub struct Signer<'a> { cookie: Cookie, position: u64, } +assert_send_and_sync!{Signer<'_>} impl<'a> Signer<'a> { /// Creates a signer. @@ -1276,6 +1280,7 @@ pub struct LiteralWriter<'a> { inner: writer::BoxStack<'a, Cookie>, signature_writer: Option>, } +assert_send_and_sync!{LiteralWriter<'_>} impl<'a> LiteralWriter<'a> { /// Creates a new literal writer. @@ -1548,6 +1553,7 @@ pub struct Compressor<'a> { level: CompressionLevel, inner: writer::BoxStack<'a, Cookie>, } +assert_send_and_sync!{Compressor<'_>} impl<'a> Compressor<'a> { /// Creates a new compressor using the default algorithm and @@ -2081,6 +2087,7 @@ pub struct Encryptor<'a> { hash: Box, cookie: Cookie, } +assert_send_and_sync!{Encryptor<'_>} impl<'a> Encryptor<'a> { /// Creates a new encryptor for the given recipients. @@ -3298,12 +3305,4 @@ mod test { Ok(()) } - - #[test] - fn message_is_send_and_sync() { - fn f(_: T) {} - let mut sink = vec![]; - let message = Message::new(&mut sink); - f(message); - } } diff --git a/openpgp/src/serialize/stream/padding.rs b/openpgp/src/serialize/stream/padding.rs index 99d815af..99eef521 100644 --- a/openpgp/src/serialize/stream/padding.rs +++ b/openpgp/src/serialize/stream/padding.rs @@ -144,6 +144,7 @@ pub struct Padder<'a> { inner: writer::BoxStack<'a, Cookie>, policy: fn(u64) -> u64, } +assert_send_and_sync!{Padder<'_>} impl<'a> Padder<'a> { /// Creates a new padder with the given policy. -- cgit v1.2.3