diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-06-08 12:28:07 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-06-08 12:28:07 +0200 |
commit | 5be97d9c6ee82f068a5b38aa455f31497d3f20bf (patch) | |
tree | 81bb1b9a737916a065b2cb24aec6c9a675cd08d7 /openpgp/src/parse/packet_parser_builder.rs | |
parent | a2cb2c31b1d63a71fdcdd19c4eafd14882c96bcc (diff) |
openpgp: Add example.
- See #471.
Diffstat (limited to 'openpgp/src/parse/packet_parser_builder.rs')
-rw-r--r-- | openpgp/src/parse/packet_parser_builder.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/openpgp/src/parse/packet_parser_builder.rs b/openpgp/src/parse/packet_parser_builder.rs index 2d0faf9a..9378aaba 100644 --- a/openpgp/src/parse/packet_parser_builder.rs +++ b/openpgp/src/parse/packet_parser_builder.rs @@ -309,7 +309,29 @@ impl<'a> PacketParserBuilder<'a> { self } - /// How to treat the input stream. + /// Controls dearmoring. + /// + /// By default, if the input does not appear to be plain binary + /// OpenPGP data, we assume that it is ASCII-armored. This method + /// can be used to tweak the behavior. See [`Dearmor`] for + /// details. + /// + /// [`Dearmor`]: enum.Dearmor.html + /// + /// # Examples + /// + /// ``` + /// # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { + /// use sequoia_openpgp as openpgp; + /// use openpgp::parse::{Parse, PacketParserBuilder, Dearmor}; + /// + /// let message_data = b"\xcb\x12t\x00\x00\x00\x00\x00Hello world."; + /// let pp = PacketParserBuilder::from_bytes(message_data)? + /// .dearmor(Dearmor::Disabled) // Disable dearmoring. + /// .build()? + /// .expect("One packet, not EOF"); + /// # Ok(()) } + /// ``` pub fn dearmor(mut self, mode: Dearmor) -> Self { self.dearmor = mode; self |