diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-05-06 13:32:13 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-05-06 18:38:19 +0200 |
commit | 320884d10326fe186e974352391d51caa5cde571 (patch) | |
tree | 141d749c79f46183dfb2bd01e7cd7ae659292921 /openpgp-ffi/src/parse/stream.rs | |
parent | c575a9b4d3d0644457d3a2ddfbfa0160d3490f19 (diff) |
openpgp: Streamline iteration over MessageStructure.
- Implement IntoIter and Deref to &'a [MessageLayer<'a>], drop the
custom iteration structs.
Diffstat (limited to 'openpgp-ffi/src/parse/stream.rs')
-rw-r--r-- | openpgp-ffi/src/parse/stream.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/openpgp-ffi/src/parse/stream.rs b/openpgp-ffi/src/parse/stream.rs index 9e23cb47..da9d45c3 100644 --- a/openpgp-ffi/src/parse/stream.rs +++ b/openpgp-ffi/src/parse/stream.rs @@ -59,14 +59,15 @@ pub struct MessageStructure<'a>(stream::MessageStructure<'a>); /// Iterates over the message structure. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn pgp_message_structure_iter(structure: *const MessageStructure) - -> *mut MessageStructureIter { - structure.ref_raw().iter().move_into_raw() +fn pgp_message_structure_into_iter(structure: *mut MessageStructure) + -> *mut MessageStructureIter { + structure.move_from_raw().into_iter().move_into_raw() } /// Iterates over the message structure. #[crate::ffi_wrapper_type(prefix = "pgp_", derive = "Iterator(MessageLayer)")] -pub struct MessageStructureIter<'a>(stream::MessageStructureIter<'a>); +pub struct MessageStructureIter<'a>( + std::vec::IntoIter<stream::MessageLayer<'a>>); /// Represents a layer of the message structure. #[crate::ffi_wrapper_type(prefix = "pgp_", derive = "Debug")] @@ -570,7 +571,7 @@ impl VerificationHelper for VHelper { /// check_cb (void *cookie_opaque, pgp_message_structure_t structure) /// { /// pgp_message_structure_iter_t iter = -/// pgp_message_structure_iter (structure); +/// pgp_message_structure_into_iter (structure); /// pgp_message_layer_t layer = pgp_message_structure_iter_next (iter); /// assert (layer); /// assert (pgp_message_layer_compression (layer, NULL)); @@ -591,7 +592,6 @@ impl VerificationHelper for VHelper { /// pgp_verification_result_iter_free (results); /// pgp_message_layer_free (layer); /// pgp_message_structure_iter_free (iter); -/// pgp_message_structure_free (structure); /// return PGP_STATUS_SUCCESS; /// } /// @@ -697,7 +697,7 @@ pub struct DetachedVerifier(openpgp::parse::stream::DetachedVerifier<'static, VH /// check_cb (void *cookie_opaque, pgp_message_structure_t structure) /// { /// pgp_message_structure_iter_t iter = -/// pgp_message_structure_iter (structure); +/// pgp_message_structure_into_iter (structure); /// pgp_message_layer_t layer = pgp_message_structure_iter_next (iter); /// assert (layer); /// pgp_verification_result_iter_t results; @@ -714,7 +714,6 @@ pub struct DetachedVerifier(openpgp::parse::stream::DetachedVerifier<'static, VH /// pgp_verification_result_iter_free (results); /// pgp_message_layer_free (layer); /// pgp_message_structure_iter_free (iter); -/// pgp_message_structure_free (structure); /// return PGP_STATUS_SUCCESS; /// } /// @@ -932,13 +931,12 @@ impl DecryptionHelper for DHelper { /// check_cb (void *cookie_opaque, pgp_message_structure_t structure) /// { /// pgp_message_structure_iter_t iter = -/// pgp_message_structure_iter (structure); +/// pgp_message_structure_into_iter (structure); /// pgp_message_layer_t layer = pgp_message_structure_iter_next (iter); /// assert (layer); /// assert (pgp_message_layer_encryption (layer, NULL, NULL)); /// pgp_message_layer_free (layer); /// pgp_message_structure_iter_free (iter); -/// pgp_message_structure_free (structure); /// return PGP_STATUS_SUCCESS; /// } /// |