diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-08-19 11:31:42 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-08-19 11:58:47 +0200 |
commit | 935734bf148efcaa69496bfe41c6f53907c5066f (patch) | |
tree | 39c6d082acfb7f62d28079df7a6bd59bc56d55c2 | |
parent | ee55b20057fbcc2b77bb5c51f4915f9f785b200b (diff) |
openpgp: Rename SubpacketArea::lookup to SubpacketArea::subpacket.
- Make `SubpacketArea::lookup`'s name more consistent with
`SubpacketArea::subpackets`, `SubpacketAreas::subpacket`, and
`SubpacketAreas::subpackets`.
-rw-r--r-- | openpgp/src/cert/builder.rs | 2 | ||||
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 12 | ||||
-rw-r--r-- | openpgp/src/types/timestamp.rs | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs index e6a6f6bf..f5667cd7 100644 --- a/openpgp/src/cert/builder.rs +++ b/openpgp/src/cert/builder.rs @@ -1198,7 +1198,7 @@ mod tests { .generate().unwrap(); let sig_pkts = cert1.subkeys().next().unwrap().bundle().self_signatures[0].hashed_area(); - match sig_pkts.lookup(SubpacketTag::KeyFlags).unwrap().value() { + match sig_pkts.subpacket(SubpacketTag::KeyFlags).unwrap().value() { SubpacketValue::KeyFlags(ref ks) => assert!(ks.for_certification()), v => panic!("Unexpected subpacket: {:?}", v), } diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index 086f61dc..24afa980 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -677,13 +677,13 @@ impl SubpacketArea { /// # // Verify it. /// # sig.verify_message(signer.public(), msg)?; /// # - /// if sig.hashed_area().lookup(SubpacketTag::SignatureCreationTime).is_none() { + /// if sig.hashed_area().subpacket(SubpacketTag::SignatureCreationTime).is_none() { /// eprintln!("Invalid signature."); /// } /// # Ok(()) /// # } /// ``` - pub fn lookup(&self, tag: SubpacketTag) -> Option<&Subpacket> { + pub fn subpacket(&self, tag: SubpacketTag) -> Option<&Subpacket> { self.cache_init(); match self.parsed.lock().unwrap().borrow().as_ref().unwrap().get(&tag) { @@ -695,13 +695,13 @@ impl SubpacketArea { /// Returns all instances of the specified subpacket. /// /// For most subpackets, only a single instance of the subpacket - /// makes sense. [`SubpacketArea::lookup`] resolves this + /// makes sense. [`SubpacketArea::subpacket`] resolves this /// ambiguity by returning the last instance of the request /// subpacket type. But, for some subpackets, like the [`Notation /// Data`] subpacket, multiple instances of the subpacket are /// reasonable. /// - /// [`SubpacketArea::lookup`]: #method.lookup + /// [`SubpacketArea::subpacket`]: #method.subpacket /// [`Notation Data`]: https://tools.ietf.org/html/rfc4880#section-5.2.3.16 /// /// # Examples @@ -2895,7 +2895,7 @@ impl SubpacketAreas { /// For subpackets that can safely occur in both subpacket areas, /// this function prefers instances in the hashed subpacket area. pub fn subpacket<'a>(&'a self, tag: SubpacketTag) -> Option<&Subpacket> { - if let Some(sb) = self.hashed_area().lookup(tag) { + if let Some(sb) = self.hashed_area().subpacket(tag) { return Some(sb); } @@ -2908,7 +2908,7 @@ impl SubpacketAreas { return None; } - self.unhashed_area().lookup(tag) + self.unhashed_area().subpacket(tag) } /// Returns an iterator over all instances of the specified diff --git a/openpgp/src/types/timestamp.rs b/openpgp/src/types/timestamp.rs index 95cfbfe8..8114df53 100644 --- a/openpgp/src/types/timestamp.rs +++ b/openpgp/src/types/timestamp.rs @@ -47,7 +47,7 @@ use crate::{ /// let subkey = cert.keys().subkeys().next().unwrap(); /// let packets = subkey.bundle().self_signatures()[0].hashed_area(); /// -/// match packets.lookup(SubpacketTag::SignatureCreationTime).unwrap().value() { +/// match packets.subpacket(SubpacketTag::SignatureCreationTime).unwrap().value() { /// SubpacketValue::SignatureCreationTime(ts) => assert!(u32::from(*ts) > 0), /// v => panic!("Unexpected subpacket: {:?}", v), /// } |