From 3bdc218a8b3582b66fc7c6c8d9f2146ddb1ef6b5 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 19 Aug 2019 12:05:40 +0200 Subject: openpgp: Rename sigtype to typ, set_sigtype to set_typ. - 'sig' in method names on Signature and OnePassSig is redundant, and 'sigtype' is likely inherited from other implementations. - Fixes #326. --- tool/src/commands/dump.rs | 4 +-- tool/src/commands/inspect.rs | 2 +- tool/tests/sq-sign.rs | 72 ++++++++++++++++++++++---------------------- 3 files changed, 39 insertions(+), 39 deletions(-) (limited to 'tool') diff --git a/tool/src/commands/dump.rs b/tool/src/commands/dump.rs index 3cdd7c0a..27619b7a 100644 --- a/tool/src/commands/dump.rs +++ b/tool/src/commands/dump.rs @@ -260,7 +260,7 @@ impl PacketDumper { Signature(ref s) => { writeln!(output, "Signature Packet")?; writeln!(output, "{} Version: {}", i, s.version())?; - writeln!(output, "{} Type: {}", i, s.sigtype())?; + writeln!(output, "{} Type: {}", i, s.typ())?; writeln!(output, "{} Pk algo: {}", i, s.pk_algo())?; writeln!(output, "{} Hash algo: {}", i, s.hash_algo())?; if s.hashed_area().iter().count() > 0 { @@ -333,7 +333,7 @@ impl PacketDumper { OnePassSig(ref o) => { writeln!(output, "One-Pass Signature Packet")?; writeln!(output, "{} Version: {}", i, o.version())?; - writeln!(output, "{} Type: {}", i, o.sigtype())?; + writeln!(output, "{} Type: {}", i, o.typ())?; writeln!(output, "{} Pk algo: {}", i, o.pk_algo())?; writeln!(output, "{} Hash algo: {}", i, o.hash_algo())?; writeln!(output, "{} Issuer: {}", i, o.issuer())?; diff --git a/tool/src/commands/inspect.rs b/tool/src/commands/inspect.rs index a1997b7c..3dbd27e0 100644 --- a/tool/src/commands/inspect.rs +++ b/tool/src/commands/inspect.rs @@ -253,7 +253,7 @@ fn inspect_signatures(output: &mut io::Write, sigs: &[openpgp::packet::Signature]) -> Result<()> { use crate::openpgp::constants::SignatureType::*; for sig in sigs { - match sig.sigtype() { + match sig.typ() { Binary | Text => (), signature_type @ _ => writeln!(output, " Kind: {}", signature_type)?, diff --git a/tool/tests/sq-sign.rs b/tool/tests/sq-sign.rs index e5624f21..b8325eb9 100644 --- a/tool/tests/sq-sign.rs +++ b/tool/tests/sq-sign.rs @@ -42,7 +42,7 @@ fn sq_sign() { assert_eq!(packets.len(), 3); if let Packet::OnePassSig(ref ops) = packets[0] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } @@ -52,7 +52,7 @@ fn sq_sign() { panic!("expected literal"); } if let Packet::Signature(ref sig) = packets[2] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); } else { panic!("expected signature"); } @@ -96,7 +96,7 @@ fn sq_sign_append() { assert_eq!(packets.len(), 3); if let Packet::OnePassSig(ref ops) = packets[0] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } @@ -106,7 +106,7 @@ fn sq_sign_append() { panic!("expected literal"); } if let Packet::Signature(ref sig) = packets[2] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); } else { panic!("expected signature"); } @@ -146,13 +146,13 @@ fn sq_sign_append() { assert_eq!(packets.len(), 5); if let Packet::OnePassSig(ref ops) = packets[0] { assert!(! ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } if let Packet::OnePassSig(ref ops) = packets[1] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } @@ -162,13 +162,13 @@ fn sq_sign_append() { panic!("expected literal"); } if let Packet::Signature(ref sig) = packets[3] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 0); } else { panic!("expected signature"); } if let Packet::Signature(ref sig) = packets[4] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 0); } else { panic!("expected signature"); @@ -235,7 +235,7 @@ fn sq_sign_append_on_compress_then_sign() { assert_eq!(packets.len(), 3); if let Packet::OnePassSig(ref ops) = packets[0] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } @@ -245,7 +245,7 @@ fn sq_sign_append_on_compress_then_sign() { panic!("expected compressed data"); } if let Packet::Signature(ref sig) = packets[2] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); } else { panic!("expected signature"); } @@ -286,13 +286,13 @@ fn sq_sign_append_on_compress_then_sign() { assert_eq!(packets.len(), 5); if let Packet::OnePassSig(ref ops) = packets[0] { assert!(! ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } if let Packet::OnePassSig(ref ops) = packets[1] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } @@ -302,13 +302,13 @@ fn sq_sign_append_on_compress_then_sign() { panic!("expected compressed data"); } if let Packet::Signature(ref sig) = packets[3] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 0); } else { panic!("expected signature"); } if let Packet::Signature(ref sig) = packets[4] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 0); } else { panic!("expected signature"); @@ -362,7 +362,7 @@ fn sq_sign_detached() { PacketPile::from_file(&sig).unwrap().into_children().collect(); assert_eq!(packets.len(), 1); if let Packet::Signature(ref sig) = packets[0] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); } else { panic!("expected signature"); } @@ -408,7 +408,7 @@ fn sq_sign_detached_append() { PacketPile::from_file(&sig).unwrap().into_children().collect(); assert_eq!(packets.len(), 1); if let Packet::Signature(ref sig) = packets[0] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); } else { panic!("expected signature"); } @@ -464,12 +464,12 @@ fn sq_sign_detached_append() { PacketPile::from_file(&sig).unwrap().into_children().collect(); assert_eq!(packets.len(), 2); if let Packet::Signature(ref sig) = packets[0] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); } else { panic!("expected signature"); } if let Packet::Signature(ref sig) = packets[1] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); } else { panic!("expected signature"); } @@ -524,12 +524,12 @@ fn sq_sign_detached_append() { PacketPile::from_file(&sig).unwrap().into_children().collect(); assert_eq!(packets.len(), 2); if let Packet::Signature(ref sig) = packets[0] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); } else { panic!("expected signature"); } if let Packet::Signature(ref sig) = packets[1] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); } else { panic!("expected signature"); } @@ -562,19 +562,19 @@ fn sq_sign_append_a_notarization() { assert_eq!(packets.len(), 7); if let Packet::OnePassSig(ref ops) = packets[0] { assert!(! ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } if let Packet::OnePassSig(ref ops) = packets[1] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } if let Packet::OnePassSig(ref ops) = packets[2] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } @@ -584,19 +584,19 @@ fn sq_sign_append_a_notarization() { panic!("expected literal"); } if let Packet::Signature(ref sig) = packets[4] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 0); } else { panic!("expected signature"); } if let Packet::Signature(ref sig) = packets[5] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 1); } else { panic!("expected signature"); } if let Packet::Signature(ref sig) = packets[6] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 1); } else { panic!("expected signature"); @@ -660,13 +660,13 @@ fn sq_sign_notarize() { assert_eq!(packets.len(), 5); if let Packet::OnePassSig(ref ops) = packets[0] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } if let Packet::OnePassSig(ref ops) = packets[1] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } @@ -676,13 +676,13 @@ fn sq_sign_notarize() { panic!("expected literal"); } if let Packet::Signature(ref sig) = packets[3] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 0); } else { panic!("expected signature"); } if let Packet::Signature(ref sig) = packets[4] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 1); } else { panic!("expected signature"); @@ -737,19 +737,19 @@ fn sq_sign_notarize_a_notarization() { assert_eq!(packets.len(), 7); if let Packet::OnePassSig(ref ops) = packets[0] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } if let Packet::OnePassSig(ref ops) = packets[1] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } if let Packet::OnePassSig(ref ops) = packets[2] { assert!(ops.last()); - assert_eq!(ops.sigtype(), SignatureType::Binary); + assert_eq!(ops.typ(), SignatureType::Binary); } else { panic!("expected one pass signature"); } @@ -759,19 +759,19 @@ fn sq_sign_notarize_a_notarization() { panic!("expected literal"); } if let Packet::Signature(ref sig) = packets[4] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 0); } else { panic!("expected signature"); } if let Packet::Signature(ref sig) = packets[5] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 1); } else { panic!("expected signature"); } if let Packet::Signature(ref sig) = packets[6] { - assert_eq!(sig.sigtype(), SignatureType::Binary); + assert_eq!(sig.typ(), SignatureType::Binary); assert_eq!(sig.level(), 2); } else { panic!("expected signature"); -- cgit v1.2.3