summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/src/packet_pile.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-01-29 18:36:16 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-01-29 18:36:16 +0100
commit6e1921660b8eb8c86b7073a34e9bd779388694bd (patch)
treef0988425947c5a1be48c0c0644a1b4e309e17528 /openpgp-ffi/src/packet_pile.rs
parent558a684ce0a2aadd6bfa7a4cda19e8a6de062e1c (diff)
openpgp-ffi: Derive Parse.
Diffstat (limited to 'openpgp-ffi/src/packet_pile.rs')
-rw-r--r--openpgp-ffi/src/packet_pile.rs52
1 files changed, 2 insertions, 50 deletions
diff --git a/openpgp-ffi/src/packet_pile.rs b/openpgp-ffi/src/packet_pile.rs
index e1aa97fe..6691bd17 100644
--- a/openpgp-ffi/src/packet_pile.rs
+++ b/openpgp-ffi/src/packet_pile.rs
@@ -5,9 +5,7 @@
//!
//! [`sequoia-openpgp::PacketPile`]: ../../sequoia_openpgp/struct.PacketPile.html
-use std::slice;
-use std::io::{Read, Write};
-use libc::{uint8_t, c_char, size_t};
+use std::io::Write;
extern crate sequoia_openpgp as openpgp;
use self::openpgp::{
@@ -15,7 +13,6 @@ use self::openpgp::{
serialize::Serialize,
};
-use Maybe;
use ::error::Status;
/// A `PacketPile` holds a deserialized sequence of OpenPGP messages.
@@ -24,50 +21,5 @@ use ::error::Status;
///
/// [`sequoia-openpgp::PacketPile`]: ../../sequoia_openpgp/struct.PacketPile.html
#[::ffi_wrapper_type(prefix = "pgp_",
- derive = "Clone, Debug, PartialEq, Serialize")]
+ derive = "Clone, Debug, PartialEq, Parse, Serialize")]
pub struct PacketPile(openpgp::PacketPile);
-
-/// Deserializes the OpenPGP message stored in a `std::io::Read`
-/// object.
-///
-/// Although this method is easier to use to parse an OpenPGP
-/// message than a `PacketParser` or a `PacketPileParser`, this
-/// interface buffers the whole message in memory. Thus, the
-/// caller must be certain that the *deserialized* message is not
-/// too large.
-///
-/// Note: this interface *does* buffer the contents of packets.
-#[::ffi_catch_abort] #[no_mangle] pub extern "system"
-fn pgp_packet_pile_from_reader(errp: Option<&mut *mut ::error::Error>,
- reader: *mut Box<Read>)
- -> Maybe<PacketPile> {
- let reader = ffi_param_ref_mut!(reader);
- openpgp::PacketPile::from_reader(reader).move_into_raw(errp)
-}
-
-/// Deserializes the OpenPGP message stored in the file named by
-/// `filename`.
-///
-/// See `pgp_packet_pile_from_reader` for more details and caveats.
-#[::ffi_catch_abort] #[no_mangle] pub extern "system"
-fn pgp_packet_pile_from_file(errp: Option<&mut *mut ::error::Error>,
- filename: *const c_char)
- -> Maybe<PacketPile> {
- let filename = ffi_param_cstr!(filename).to_string_lossy().into_owned();
- openpgp::PacketPile::from_file(&filename).move_into_raw(errp)
-}
-
-/// Deserializes the OpenPGP message stored in the provided buffer.
-///
-/// See `pgp_packet_pile_from_reader` for more details and caveats.
-#[::ffi_catch_abort] #[no_mangle] pub extern "system"
-fn pgp_packet_pile_from_bytes(errp: Option<&mut *mut ::error::Error>,
- b: *const uint8_t, len: size_t)
- -> Maybe<PacketPile> {
- assert!(!b.is_null());
- let buf = unsafe {
- slice::from_raw_parts(b, len as usize)
- };
-
- openpgp::PacketPile::from_bytes(buf).move_into_raw(errp)
-}