diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-12-07 16:20:59 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-12-07 16:48:23 +0100 |
commit | 58286b06295c95f77b1bb2cb28dc247238080a7a (patch) | |
tree | d847311b7c13b4af7914827c6d551c7163cef9fc /openpgp | |
parent | 0768b36c4dd9bddd6b85a7017c32e44ad9775db5 (diff) |
openpgp: Make PacketParser's map field private.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/parse/map.rs | 4 | ||||
-rw-r--r-- | openpgp/src/parse/parse.rs | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/openpgp/src/parse/map.rs b/openpgp/src/parse/map.rs index ed286977..434c0e93 100644 --- a/openpgp/src/parse/map.rs +++ b/openpgp/src/parse/map.rs @@ -65,8 +65,8 @@ impl Map { /// let msg = b"\xcb\x12t\x00\x00\x00\x00\x00Hello world."; /// let ppo = PacketParserBuilder::from_bytes(msg)? /// .map(true).finalize()?; - /// let map = ppo.unwrap().map.unwrap(); - /// assert_eq!(map.iter().map(|f| (f.name, f.data)).collect::<Vec<(&str, &[u8])>>(), + /// assert_eq!(ppo.unwrap().map().unwrap().iter() + /// .map(|f| (f.name, f.data)).collect::<Vec<(&str, &[u8])>>(), /// [("frame", &b"\xcb\x12"[..]), /// ("format", b"t"), /// ("filename_len", b"\x00"), diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs index 396d8c53..60b95ec3 100644 --- a/openpgp/src/parse/parse.rs +++ b/openpgp/src/parse/parse.rs @@ -2157,7 +2157,7 @@ pub struct PacketParser<'a> { decrypted: bool, /// A map of this packet. - pub map: Option<map::Map>, + map: Option<map::Map>, state: PacketParserState, } @@ -3032,6 +3032,16 @@ impl <'a> PacketParser<'a> { Ok(&mut self.packet) } + + /// Returns a reference to the map (if any is written). + pub fn map(&self) -> Option<&map::Map> { + self.map.as_ref() + } + + /// Takes the map (if any is written). + pub fn take_map(&mut self) -> Option<map::Map> { + self.map.take() + } } /// This interface allows a caller to read the content of a |