diff options
-rw-r--r-- | openpgp/src/armor.rs | 6 | ||||
-rw-r--r-- | openpgp/src/cert.rs | 2 | ||||
-rw-r--r-- | openpgp/src/cert/amalgamation.rs | 14 | ||||
-rw-r--r-- | openpgp/src/cert/amalgamation/key.rs | 14 | ||||
-rw-r--r-- | openpgp/src/cert/amalgamation/key/iter.rs | 20 | ||||
-rw-r--r-- | openpgp/src/cert/parser/mod.rs | 2 | ||||
-rw-r--r-- | openpgp/src/fmt.rs | 12 | ||||
-rw-r--r-- | openpgp/src/keyhandle.rs | 10 | ||||
-rw-r--r-- | openpgp/src/packet/key.rs | 4 | ||||
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 10 | ||||
-rw-r--r-- | openpgp/src/packet/userid.rs | 8 | ||||
-rw-r--r-- | openpgp/src/packet_pile.rs | 3 | ||||
-rw-r--r-- | openpgp/src/types/mod.rs | 4 |
13 files changed, 64 insertions, 45 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs index 1ef5d5ef..f2d83c67 100644 --- a/openpgp/src/armor.rs +++ b/openpgp/src/armor.rs @@ -18,12 +18,14 @@ //! # Examples //! //! ```rust, no_run +//! # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { //! use sequoia_openpgp as openpgp; //! use std::fs::File; //! use openpgp::armor::{Reader, ReaderMode, Kind}; //! -//! let mut file = File::open("somefile.asc").unwrap(); +//! let mut file = File::open("somefile.asc")?; //! let mut r = Reader::new(&mut file, ReaderMode::Tolerant(Some(Kind::File))); +//! # Ok(()) } //! ``` use base64; @@ -673,7 +675,7 @@ impl<'a> Reader<'a> { /// /// let mut content = String::new(); /// reader.read_to_string(&mut content)?; - /// assert_eq!(reader.headers().unwrap(), + /// assert_eq!(reader.headers()?, /// &[("First".into(), "value".into()), /// ("Header".into(), "value".into())]); /// # Ok(()) diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs index ca010f19..2755eb7e 100644 --- a/openpgp/src/cert.rs +++ b/openpgp/src/cert.rs @@ -1174,7 +1174,7 @@ impl Cert { /// # let tag = Tag::Private(61); /// # let unknown /// # = Unknown::new(tag, openpgp::Error::UnsupportedPacketType(tag).into()); - /// # let cert = cert.insert_packets(unknown).unwrap(); + /// # let cert = cert.insert_packets(unknown)?; /// println!("{}'s has {} unknown components.", /// cert.fingerprint(), /// cert.unknowns().count()); diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs index 786dcca7..883e024a 100644 --- a/openpgp/src/cert/amalgamation.rs +++ b/openpgp/src/cert/amalgamation.rs @@ -153,6 +153,7 @@ //! code, which doesn't compile: //! //! ```compile_fail +//! # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { //! # use sequoia_openpgp as openpgp; //! use openpgp::cert::prelude::*; //! use openpgp::packet::prelude::*; @@ -161,7 +162,7 @@ //! # .add_userid("Alice") //! # .add_signing_subkey() //! # .add_transport_encryption_subkey() -//! # .generate().unwrap(); +//! # .generate()?; //! cert.userids() //! .map(|ua| { //! // Use auto deref to get the containing `&ComponentBundle`. @@ -169,6 +170,7 @@ //! b //! }) //! .collect::<Vec<&UserID>>(); +//! # Ok(()) } //! ``` //! //! Compiling it results in the following error: @@ -186,6 +188,7 @@ //! below for the [`ComponentAmalgamation::component`] method: //! //! ``` +//! # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { //! # use sequoia_openpgp as openpgp; //! use openpgp::cert::prelude::*; //! use openpgp::packet::prelude::*; @@ -194,7 +197,7 @@ //! # .add_userid("Alice") //! # .add_signing_subkey() //! # .add_transport_encryption_subkey() -//! # .generate().unwrap(); +//! # .generate()?; //! cert.userids() //! .map(|ua| { //! // ua's lifetime is this closure. But `component()` @@ -203,6 +206,7 @@ //! ua.component() //! }) //! .collect::<Vec<&UserID>>(); +//! # Ok(()) } //! ``` //! //! [`ComponentBundle`]: ../bundle/index.html @@ -754,6 +758,7 @@ impl<'a, C> ComponentAmalgamation<'a, C> { /// # Examples /// /// ``` + /// # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { /// # use sequoia_openpgp as openpgp; /// use openpgp::cert::prelude::*; /// use openpgp::packet::prelude::*; @@ -762,7 +767,7 @@ impl<'a, C> ComponentAmalgamation<'a, C> { /// # .add_userid("Alice") /// # .add_signing_subkey() /// # .add_transport_encryption_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// cert.userids() /// .map(|ua| { /// // The following doesn't work: @@ -776,6 +781,7 @@ impl<'a, C> ComponentAmalgamation<'a, C> { /// ua.bundle() /// }) /// .collect::<Vec<&ComponentBundle<_>>>(); + /// # Ok(()) } /// ``` pub fn bundle(&self) -> &'a ComponentBundle<C> { &self.bundle @@ -1038,7 +1044,7 @@ impl<'a> UserAttributeAmalgamation<'a> { /// # .add_userid("Alice") /// # .add_signing_subkey() /// # .add_transport_encryption_subkey() -/// # .generate().unwrap(); +/// # .generate()?; /// for u in cert.userids() { /// // Create a `ValidComponentAmalgamation`. This may fail if /// // there are no binding signatures that are accepted by the diff --git a/openpgp/src/cert/amalgamation/key.rs b/openpgp/src/cert/amalgamation/key.rs index 543da96f..d06d1840 100644 --- a/openpgp/src/cert/amalgamation/key.rs +++ b/openpgp/src/cert/amalgamation/key.rs @@ -45,6 +45,7 @@ //! vice versa even though we support changing a `KeyBundle`'s role: //! //! ``` +//! # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { //! # use std::convert::TryInto; //! # use sequoia_openpgp as openpgp; //! # use openpgp::cert::prelude::*; @@ -53,7 +54,7 @@ //! # .add_userid("Alice") //! # .add_signing_subkey() //! # .add_transport_encryption_subkey() -//! # .generate().unwrap(); +//! # .generate()?; //! // This works: //! cert.primary_key().bundle().role_as_subordinate(); //! @@ -61,6 +62,7 @@ //! let ka: ErasedKeyAmalgamation<_> = cert.keys().nth(0).expect("primary key"); //! let ka: openpgp::Result<SubordinateKeyAmalgamation<key::PublicParts>> = ka.try_into(); //! assert!(ka.is_err()); +//! # Ok(()) } //! ``` //! //! The use of the prefix `Erased` instead of `Unspecified` @@ -1311,7 +1313,7 @@ impl<'a, P, R, R2> ValidKeyAmalgamation<'a, P, R, R2> /// # .add_userid("Alice") /// # .add_signing_subkey() /// # .add_transport_encryption_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// let ka = cert.primary_key().with_policy(p, None)?; /// if let Err(_err) = ka.alive() { /// // Not alive. @@ -1359,7 +1361,7 @@ impl<'a, P, R, R2> ValidKeyAmalgamation<'a, P, R, R2> /// # .add_userid("Alice") /// # .add_signing_subkey() /// # .add_transport_encryption_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// let ka = cert.primary_key(); /// /// // `with_policy` takes ownership of `ka`. @@ -1431,7 +1433,7 @@ impl<'a, P> ValidPrimaryKeyAmalgamation<'a, P> /// # .add_userid("Alice") /// # .add_signing_subkey() /// # .add_transport_encryption_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// let vc = cert.with_policy(p, None)?; /// /// // Assert that the primary key is not expired. @@ -1513,7 +1515,7 @@ impl<'a, P> ValidSubordinateKeyAmalgamation<'a, P> /// # .add_userid("Alice") /// # .add_signing_subkey() /// # .add_transport_encryption_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// let vc = cert.with_policy(p, None)?; /// /// // Assert that the keys are not expired. @@ -1751,7 +1753,7 @@ impl<'a, P> ValidErasedKeyAmalgamation<'a, P> /// # .add_userid("Alice") /// # .add_signing_subkey() /// # .add_transport_encryption_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// let vc = cert.with_policy(p, None)?; /// /// // Assert that the keys are not expired. diff --git a/openpgp/src/cert/amalgamation/key/iter.rs b/openpgp/src/cert/amalgamation/key/iter.rs index 9d4d6ce7..edc98f57 100644 --- a/openpgp/src/cert/amalgamation/key/iter.rs +++ b/openpgp/src/cert/amalgamation/key/iter.rs @@ -467,7 +467,7 @@ impl<'a, P, R> KeyAmalgamationIter<'a, P, R> /// # .add_transport_encryption_subkey() /// # .add_storage_encryption_subkey() /// # .add_authentication_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// # let mut i = 0; /// for ka in cert.keys().subkeys() { /// // Use it. @@ -942,7 +942,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> /// # .add_transport_encryption_subkey() /// # .add_storage_encryption_subkey() /// # .add_authentication_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// # let mut i = 0; /// for ka in cert.keys() /// .with_policy(p, None) @@ -1012,7 +1012,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> /// # .add_transport_encryption_subkey() /// # .add_storage_encryption_subkey() /// # .add_authentication_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// # let mut i = 0; /// for ka in cert.keys() /// .with_policy(p, None) @@ -1057,7 +1057,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> /// # .add_transport_encryption_subkey() /// # .add_storage_encryption_subkey() /// # .add_authentication_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// # let mut i = 0; /// for ka in cert.keys() /// .with_policy(p, None) @@ -1100,7 +1100,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> /// # .add_transport_encryption_subkey() /// # .add_storage_encryption_subkey() /// # .add_authentication_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// # let mut i = 0; /// for ka in cert.keys() /// .with_policy(p, None) @@ -1143,7 +1143,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> /// # .add_transport_encryption_subkey() /// # .add_storage_encryption_subkey() /// # .add_authentication_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// # let mut i = 0; /// for ka in cert.keys() /// .with_policy(p, None) @@ -1186,7 +1186,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> /// # .add_transport_encryption_subkey() /// # .add_transport_encryption_subkey() /// # .add_authentication_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// # let mut i = 0; /// for ka in cert.keys() /// .with_policy(p, None) @@ -1229,7 +1229,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> /// # .add_transport_encryption_subkey() /// # .add_transport_encryption_subkey() /// # .add_authentication_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// for ka in cert.keys() /// .with_policy(p, None) /// .alive() @@ -1276,7 +1276,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> /// # .add_transport_encryption_subkey() /// # .add_transport_encryption_subkey() /// # .add_authentication_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// for ka in cert.keys() /// .with_policy(p, None) /// .revoked(false) @@ -1593,7 +1593,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> /// # .add_transport_encryption_subkey() /// # .add_storage_encryption_subkey() /// # .add_authentication_subkey() - /// # .generate().unwrap(); + /// # .generate()?; /// # let mut i = 0; /// for ka in cert.keys().with_policy(p, None).subkeys() { /// assert!(! ka.primary()); diff --git a/openpgp/src/cert/parser/mod.rs b/openpgp/src/cert/parser/mod.rs index ca320cf9..ac7d535c 100644 --- a/openpgp/src/cert/parser/mod.rs +++ b/openpgp/src/cert/parser/mod.rs @@ -737,7 +737,7 @@ impl<'a> CertParser<'a> { /// # fn main() { f().unwrap(); } /// # fn f() -> Result<()> { /// # let ppr = PacketParser::from_bytes(b"")?; - /// # let some_keyid = "C2B819056C652598".parse().unwrap(); + /// # let some_keyid = "C2B819056C652598".parse()?; /// for certr in CertParser::from(ppr) /// .unvalidated_cert_filter(|cert, _| { /// for component in cert.keys() { diff --git a/openpgp/src/fmt.rs b/openpgp/src/fmt.rs index 783c1885..1921a784 100644 --- a/openpgp/src/fmt.rs +++ b/openpgp/src/fmt.rs @@ -40,20 +40,22 @@ pub mod hex { /// # Examples /// /// ```rust - /// use sequoia_openpgp::fmt::hex; + /// # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { + /// use sequoia_openpgp::fmt::hex; /// /// let mut dumper = hex::Dumper::new(Vec::new(), ""); - /// dumper.write(&[0x89, 0x01, 0x33], "frame").unwrap(); - /// dumper.write(&[0x04], "version").unwrap(); - /// dumper.write(&[0x00], "type").unwrap(); + /// dumper.write(&[0x89, 0x01, 0x33], "frame")?; + /// dumper.write(&[0x04], "version")?; + /// dumper.write(&[0x00], "type")?; /// /// let buf = dumper.into_inner(); /// assert_eq!( - /// ::std::str::from_utf8(&buf[..]).unwrap(), + /// ::std::str::from_utf8(&buf[..])?, /// "00000000 89 01 33 frame\n\ /// 00000003 04 version\n\ /// 00000004 00 type\n\ /// "); + /// # Ok(()) } /// ``` pub struct Dumper<W: io::Write> { inner: W, diff --git a/openpgp/src/keyhandle.rs b/openpgp/src/keyhandle.rs index 5506d700..709b1c93 100644 --- a/openpgp/src/keyhandle.rs +++ b/openpgp/src/keyhandle.rs @@ -246,6 +246,7 @@ impl KeyHandle { /// non-transitive equality relation: /// /// ``` + /// # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { /// # use sequoia_openpgp as openpgp; /// # use openpgp::Fingerprint; /// # use openpgp::KeyID; @@ -253,20 +254,21 @@ impl KeyHandle { /// # /// # let fpr1 : KeyHandle /// # = "8F17 7771 18A3 3DDA 9BA4 8E62 AACB 3243 6300 52D9" - /// # .parse::<Fingerprint>().unwrap().into(); + /// # .parse::<Fingerprint>()?.into(); /// # /// # let fpr2 : KeyHandle /// # = "0123 4567 8901 2345 6789 0123 AACB 3243 6300 52D9" - /// # .parse::<Fingerprint>().unwrap().into(); + /// # .parse::<Fingerprint>()?.into(); /// # - /// # let keyid : KeyHandle = "AACB 3243 6300 52D9".parse::<KeyID>() - /// # .unwrap().into(); + /// # let keyid : KeyHandle = "AACB 3243 6300 52D9".parse::<KeyID>()? + /// # .into(); /// # /// // fpr1 and fpr2 are different fingerprints with the same KeyID. /// assert!(! fpr1.eq(&fpr2)); /// assert!(fpr1.aliases(&keyid)); /// assert!(fpr2.aliases(&keyid)); /// assert!(! fpr1.aliases(&fpr2)); + /// # Ok(()) } /// ``` pub fn aliases<H>(&self, other: H) -> bool where H: Borrow<KeyHandle> diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs index 87745997..348a9396 100644 --- a/openpgp/src/packet/key.rs +++ b/openpgp/src/packet/key.rs @@ -202,7 +202,7 @@ pub trait KeyParts: fmt::Debug + seal::Sealed { /// # let (cert, _) = /// # CertBuilder::general_purpose(None, Some("alice@example.org")) /// # .generate()?; - /// # f(&cert, cert.primary_key().key().clone().role_into_unspecified()).unwrap(); + /// # f(&cert, cert.primary_key().key().clone().role_into_unspecified())?; /// # Ok(()) /// # } /// ``` @@ -384,7 +384,7 @@ pub trait KeyRole: fmt::Debug + seal::Sealed { /// # let (cert, _) = /// # CertBuilder::general_purpose(None, Some("alice@example.org")) /// # .generate()?; - /// # f(&cert, cert.primary_key().key().clone().parts_into_unspecified()).unwrap(); + /// # f(&cert, cert.primary_key().key().clone().parts_into_unspecified())?; /// # Ok(()) /// # } /// ``` diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index 0bfac9b5..35c37b09 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -3673,7 +3673,7 @@ impl signature::SignatureBuilder { /// true)?)?; /// let sig = builder.sign_message(&mut signer, msg)?; /// # let mut sig = sig; - /// # sig.verify_message(signer.public(), msg).unwrap(); + /// # sig.verify_message(signer.public(), msg)?; /// # Ok(()) } /// ``` /// @@ -3713,7 +3713,7 @@ impl signature::SignatureBuilder { /// })? /// .sign_message(&mut signer, msg)?; /// # let mut sig = sig; - /// # sig.verify_message(signer.public(), msg).unwrap(); + /// # sig.verify_message(signer.public(), msg)?; /// # Ok(()) } /// ``` /// @@ -3764,7 +3764,7 @@ impl signature::SignatureBuilder { /// })? /// .sign_message(&mut signer, msg)?; /// # let mut sig = sig; - /// # sig.verify_message(signer.public(), msg).unwrap(); + /// # sig.verify_message(signer.public(), msg)?; /// # Ok(()) } /// ``` pub fn modify_unhashed_area<F>(mut self, f: F) @@ -3819,7 +3819,7 @@ impl signature::SignatureBuilder { /// true)?)?; /// let sig = builder.sign_message(&mut signer, msg)?; /// # let mut sig = sig; - /// # sig.verify_message(signer.public(), msg).unwrap(); + /// # sig.verify_message(signer.public(), msg)?; /// # Ok(()) } /// ``` /// @@ -3859,7 +3859,7 @@ impl signature::SignatureBuilder { /// })? /// .sign_message(&mut signer, msg)?; /// # let mut sig = sig; - /// # sig.verify_message(signer.public(), msg).unwrap(); + /// # sig.verify_message(signer.public(), msg)?; /// # Ok(()) } /// ``` /// diff --git a/openpgp/src/packet/userid.rs b/openpgp/src/packet/userid.rs index 49d189bf..93d6875c 100644 --- a/openpgp/src/packet/userid.rs +++ b/openpgp/src/packet/userid.rs @@ -775,12 +775,14 @@ impl UserID { /// [conventional User ID]: #conventional-user-ids /// /// ``` + /// # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { /// # use sequoia_openpgp as openpgp; /// # use openpgp::packet::UserID; /// assert_eq!(UserID::from_address( /// "John Smith".into(), - /// None, "boat@example.org").unwrap().value(), + /// None, "boat@example.org")?.value(), /// &b"John Smith <boat@example.org>"[..]); + /// # Ok(()) } /// ``` pub fn from_address<O, S>(name: O, comment: O, email: S) -> Result<Self> @@ -808,12 +810,14 @@ impl UserID { /// [conventional User ID]: #conventional-user-ids /// /// ``` + /// # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { /// # use sequoia_openpgp as openpgp; /// # use openpgp::packet::UserID; /// assert_eq!(UserID::from_unchecked_address( /// "NAS".into(), - /// None, "ssh://host.example.org").unwrap().value(), + /// None, "ssh://host.example.org")?.value(), /// &b"NAS <ssh://host.example.org>"[..]); + /// # Ok(()) } /// ``` pub fn from_unchecked_address<O, S>(name: O, comment: O, address: S) -> Result<Self> diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs index 330d02cf..481d09f3 100644 --- a/openpgp/src/packet_pile.rs +++ b/openpgp/src/packet_pile.rs @@ -375,8 +375,7 @@ impl PacketPile { /// literal.set_body(b"new".to_vec()); /// pile.replace( /// &[0, 0], 1, - /// [literal.into()].to_vec()) - /// .unwrap(); + /// [literal.into()].to_vec())?; /// # if let Some(Packet::Literal(lit)) = pile.path_ref(&[0, 0]) { /// # assert_eq!(lit.body(), &b"new"[..], "{:#?}", lit); /// # } else { diff --git a/openpgp/src/types/mod.rs b/openpgp/src/types/mod.rs index 8e5319cd..e3f0f7a0 100644 --- a/openpgp/src/types/mod.rs +++ b/openpgp/src/types/mod.rs @@ -83,15 +83,17 @@ pub(crate) trait Syncable : Sync {} /// # Examples /// /// ```rust +/// # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { /// use sequoia_openpgp as openpgp; /// use openpgp::cert::prelude::*; /// use openpgp::types::PublicKeyAlgorithm; /// /// let (cert, _) = CertBuilder::new() /// .set_cipher_suite(CipherSuite::Cv25519) -/// .generate().unwrap(); +/// .generate()?; /// /// assert_eq!(cert.primary_key().pk_algo(), PublicKeyAlgorithm::EdDSA); +/// # Ok(()) } /// ``` /// /// [Section 9.1 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-9.1 |