diff options
author | Wiktor Kwapisiewicz <wiktor@metacode.biz> | 2020-07-27 10:15:19 +0200 |
---|---|---|
committer | Wiktor Kwapisiewicz <wiktor@metacode.biz> | 2020-08-18 10:13:16 +0200 |
commit | f76086687a3d16a97f15171fd3d966ddffb1ac95 (patch) | |
tree | 44970e4d03b831b0f5eff3fa58899c1da8da359b /openpgp | |
parent | 1a45f00bb4b9597608d1530b1cfab252e40bfd18 (diff) |
openpgp: Add Reader::headers() documentation.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/armor.rs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs index b69e890b..aa9b039e 100644 --- a/openpgp/src/armor.rs +++ b/openpgp/src/armor.rs @@ -473,7 +473,7 @@ impl<'a> Reader<'a> { /// /// [ASCII Armor]: https://tools.ietf.org/html/rfc4880#section-6.2 /// - /// # Example + /// # Examples /// /// ``` /// # use std::io::Read; @@ -600,6 +600,36 @@ impl<'a> Reader<'a> { /// Note: if a key occurs multiple times, then there are multiple /// entries in the vector with the same key; values with the same /// key are *not* combined. + /// + /// # Examples + /// + /// ``` + /// # use std::io::Read; + /// # extern crate sequoia_openpgp as openpgp; + /// # use openpgp::armor::{Reader, ReaderMode, Kind}; + /// # use std::io::{self, Result}; + /// # fn main() { f().unwrap(); } + /// # fn f() -> Result<()> { + /// let data = + /// "-----BEGIN PGP ARMORED FILE----- + /// First: value + /// Header: value + /// + /// SGVsbG8gd29ybGQh + /// =s4Gu + /// -----END PGP ARMORED FILE-----"; + /// + /// let mut cursor = io::Cursor::new(&data); + /// let mut reader = Reader::new(&mut cursor, ReaderMode::Tolerant(Some(Kind::File))); + /// + /// let mut content = String::new(); + /// reader.read_to_string(&mut content)?; + /// assert_eq!(reader.headers().unwrap(), + /// &[(" First".into(), "value".into()), + /// (" Header".into(), "value".into())]); + /// # Ok(()) + /// # } + /// ``` pub fn headers(&mut self) -> Result<&[(String, String)]> { self.initialize()?; Ok(&self.headers[..]) |