summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-04-09 15:04:32 +0200
committerJustus Winter <justus@sequoia-pgp.org>2018-04-13 09:47:13 +0200
commitcc32cff1d493376dffb86a661e39c5d79eda762c (patch)
tree3fede938982df73e45bee9b51251e46d1e609563 /openpgp
parentded74fdd9d7d5b7b1e8d3d45e29a19c4c865ea3a (diff)
openpgp: Move Message-related functionality to openpgp::message.
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/src/iter.rs46
-rw-r--r--openpgp/src/lib.rs1
-rw-r--r--openpgp/src/message.rs41
3 files changed, 41 insertions, 47 deletions
diff --git a/openpgp/src/iter.rs b/openpgp/src/iter.rs
deleted file mode 100644
index 81f7c75c..00000000
--- a/openpgp/src/iter.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-use std::slice;
-use std::vec;
-
-use Packet;
-use Message;
-use packet::{Container, PacketIter};
-
-impl Message {
- /// Turns a vector of [`Packet`s] into a `Message`.
- ///
- /// This is a simple wrapper function; it does not process the
- /// packets in any way.
- ///
- /// [`Packet`s]: struct.Packet.html
- pub fn from_packets(p: Vec<Packet>) -> Self {
- Message { top_level: Container { packets: p } }
- }
-
- /// Turns a [`Packet`] into a `Message`.
- ///
- /// This is a simple wrapper function; it does not process the
- /// packets in any way.
- ///
- /// [`Packet`]: struct.Packet.html
- pub fn from_packet(p: Packet) -> Self {
- let mut top_level = Vec::with_capacity(1);
- top_level.push(p);
- Self::from_packets(top_level)
- }
-
- /// Returns an iterator over all of the packet's descendants, in
- /// depth-first order.
- pub fn descendants(&self) -> PacketIter {
- self.top_level.descendants()
- }
-
- /// Returns an iterator over the top-level packets.
- pub fn children<'a>(&'a self) -> slice::Iter<'a, Packet> {
- self.top_level.children()
- }
-
- /// Returns an `IntoIter` over the top-level packets.
- pub fn into_children(self) -> vec::IntoIter<Packet> {
- self.top_level.into_children()
- }
-}
diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs
index 833f554f..7a1c752a 100644
--- a/openpgp/src/lib.rs
+++ b/openpgp/src/lib.rs
@@ -84,7 +84,6 @@ mod literal;
mod compressed_data;
mod skesk;
mod message;
-mod iter;
pub type Result<T> = ::std::result::Result<T, failure::Error>;
diff --git a/openpgp/src/message.rs b/openpgp/src/message.rs
index 902310ab..905641f0 100644
--- a/openpgp/src/message.rs
+++ b/openpgp/src/message.rs
@@ -1,6 +1,9 @@
use std::fmt;
+use std::slice;
+use std::vec;
use Packet;
+use packet::{Container, PacketIter};
use Message;
impl fmt::Debug for Message {
@@ -12,6 +15,28 @@ impl fmt::Debug for Message {
}
impl Message {
+ /// Turns a vector of [`Packet`s] into a `Message`.
+ ///
+ /// This is a simple wrapper function; it does not process the
+ /// packets in any way.
+ ///
+ /// [`Packet`s]: struct.Packet.html
+ pub fn from_packets(p: Vec<Packet>) -> Self {
+ Message { top_level: Container { packets: p } }
+ }
+
+ /// Turns a [`Packet`] into a `Message`.
+ ///
+ /// This is a simple wrapper function; it does not process the
+ /// packets in any way.
+ ///
+ /// [`Packet`]: struct.Packet.html
+ pub fn from_packet(p: Packet) -> Self {
+ let mut top_level = Vec::with_capacity(1);
+ top_level.push(p);
+ Self::from_packets(top_level)
+ }
+
/// Pretty prints the message to stderr.
///
/// This function is primarily intended for debugging purposes.
@@ -61,4 +86,20 @@ impl Message {
}
return packet;
}
+
+ /// Returns an iterator over all of the packet's descendants, in
+ /// depth-first order.
+ pub fn descendants(&self) -> PacketIter {
+ self.top_level.descendants()
+ }
+
+ /// Returns an iterator over the top-level packets.
+ pub fn children<'a>(&'a self) -> slice::Iter<'a, Packet> {
+ self.top_level.children()
+ }
+
+ /// Returns an `IntoIter` over the top-level packets.
+ pub fn into_children(self) -> vec::IntoIter<Packet> {
+ self.top_level.into_children()
+ }
}