[−][src]Struct sequoia_openpgp::serialize::stream::Armorer
Applies ASCII Armor to the message.
ASCII armored data (see Section 6 of RFC 4880) is a OpenPGP data stream that has been base64-encoded and decorated with a header, footer, and optional headers representing key-value pairs. It can be safely transmitted over protocols that can only transmit printable characters, and can handled by end users (e.g. copied and pasted).
Implementations
impl<'a> Armorer<'a>
[src]
pub fn new(inner: Message<'a>) -> Self
[src]
Creates a new armoring filter.
By default, the type of the armored data is set to
armor::Kind
::Message
. To change it, use
Armorer::kind
. To add headers to the armor, use
Armorer::add_header
.
Examples
use std::io::Write; use sequoia_openpgp as openpgp; use openpgp::serialize::stream::{Message, Armorer, LiteralWriter}; let mut sink = vec![]; { let message = Message::new(&mut sink); let message = Armorer::new(message) // Customize the `Armorer` here. .build()?; let mut message = LiteralWriter::new(message).build()?; message.write_all(b"Hello world.")?; message.finalize()?; } assert_eq!("-----BEGIN PGP MESSAGE-----\n\ \n\ yxJiAAAAAABIZWxsbyB3b3JsZC4=\n\ =6nHv\n\ -----END PGP MESSAGE-----\n", std::str::from_utf8(&sink)?);
pub fn kind(self, kind: Kind) -> Self
[src]
Changes the kind of armoring.
The armor header and footer changes depending on the type of
wrapped data. See armor::Kind
for the possible values.
Examples
use std::io::Write; use sequoia_openpgp as openpgp; use openpgp::armor; use openpgp::serialize::stream::{Message, Armorer, Signer}; let mut sink = vec![]; { let message = Message::new(&mut sink); let message = Armorer::new(message) .kind(armor::Kind::Signature) .build()?; let mut signer = Signer::new(message, signing_keypair) .detached() .build()?; // Write the data directly to the `Signer`. signer.write_all(b"Make it so, number one!")?; // In reality, just io::copy() the file to be signed. signer.finalize()?; } assert!(std::str::from_utf8(&sink)? .starts_with("-----BEGIN PGP SIGNATURE-----\n"));
pub fn add_header<K, V>(self, key: K, value: V) -> Self where
K: AsRef<str>,
V: AsRef<str>,
[src]
K: AsRef<str>,
V: AsRef<str>,
Adds a header to the armor block.
There are a number of defined armor header keys (see Section 6 of RFC 4880), but in practice, any key may be used, as implementations should simply ignore unknown keys.
Examples
use std::io::Write; use sequoia_openpgp as openpgp; use openpgp::serialize::stream::{Message, Armorer, LiteralWriter}; let mut sink = vec![]; { let message = Message::new(&mut sink); let message = Armorer::new(message) .add_header("Comment", "No comment.") .build()?; let mut message = LiteralWriter::new(message).build()?; message.write_all(b"Hello world.")?; message.finalize()?; } assert_eq!("-----BEGIN PGP MESSAGE-----\n\ Comment: No comment.\n\ \n\ yxJiAAAAAABIZWxsbyB3b3JsZC4=\n\ =6nHv\n\ -----END PGP MESSAGE-----\n", std::str::from_utf8(&sink)?);
pub fn build(self) -> Result<Message<'a>>
[src]
Builds the armor writer, returning the writer stack.
Examples
use sequoia_openpgp as openpgp; use openpgp::serialize::stream::{Message, Armorer, LiteralWriter}; let message = Message::new(&mut sink); let message = Armorer::new(message) // Customize the `Armorer` here. .build()?;
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Armorer<'a>
impl<'a> Send for Armorer<'a>
impl<'a> Sync for Armorer<'a>
impl<'a> Unpin for Armorer<'a>
impl<'a> !UnwindSafe for Armorer<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,