diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-02-06 14:49:01 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-02-06 15:06:09 +0100 |
commit | d6ed2a3cbb18c50c2da73d5efbdade343e3bad12 (patch) | |
tree | 15cefd9945499ab20065acb30df86d3ccd829cca | |
parent | 23110e2844a19ffdd1d5c1699cb868f93f734ccc (diff) |
openpgp: Rename methods 'set_policy' to 'with_policy'.
- Fixes #427.
34 files changed, 154 insertions, 154 deletions
diff --git a/examples/guide-exploring-openpgp.rs b/examples/guide-exploring-openpgp.rs index 6d905b9e..298fcd6c 100644 --- a/examples/guide-exploring-openpgp.rs +++ b/examples/guide-exploring-openpgp.rs @@ -55,7 +55,7 @@ fn main() { println!("Fingerprint: {}", cert.fingerprint()); // List userids. - for (i, ca) in cert.userids().set_policy(p, None).enumerate() { + for (i, ca) in cert.userids().with_policy(p, None).enumerate() { println!("{}: UID: {}, {} self-signature(s), {} certification(s)", i, ca.userid(), ca.bundle().self_signatures().len(), @@ -63,7 +63,7 @@ fn main() { } // List subkeys. - for (i, ka) in cert.keys().set_policy(p, None).skip(1).enumerate() { + for (i, ka) in cert.keys().with_policy(p, None).skip(1).enumerate() { println!("{}: Fingerprint: {}, {} self-signature(s), {} certification(s)", i, ka.key().fingerprint(), ka.bundle().self_signatures().len(), diff --git a/guide/src/chapter_01.md b/guide/src/chapter_01.md index 629515eb..178e8e83 100644 --- a/guide/src/chapter_01.md +++ b/guide/src/chapter_01.md @@ -57,7 +57,7 @@ fn main() { # -> openpgp::Result<()> # { # // Get the keypair to do the signing from the Cert. -# let keypair = tsk.keys().set_policy(policy, None) +# let keypair = tsk.keys().with_policy(policy, None) # .alive().revoked(false).for_signing().nth(0).unwrap() # .key().clone().mark_parts_secret().unwrap().into_keypair()?; # @@ -211,7 +211,7 @@ fn generate() -> openpgp::Result<openpgp::Cert> { # -> openpgp::Result<()> # { # // Get the keypair to do the signing from the Cert. -# let keypair = tsk.keys().set_policy(policy, None) +# let keypair = tsk.keys().with_policy(policy, None) # .alive().revoked(false).for_signing().nth(0).unwrap() # .key().clone().mark_parts_secret().unwrap().into_keypair()?; # @@ -365,7 +365,7 @@ fn sign(policy: &dyn Policy, -> openpgp::Result<()> { // Get the keypair to do the signing from the Cert. - let keypair = tsk.keys().set_policy(policy, None) + let keypair = tsk.keys().with_policy(policy, None) .alive().revoked(false).for_signing().nth(0).unwrap() .key().clone().mark_parts_secret().unwrap().into_keypair()?; @@ -530,7 +530,7 @@ Verified data can be read from this using [`io::Read`]. # -> openpgp::Result<()> # { # // Get the keypair to do the signing from the Cert. -# let keypair = tsk.keys().set_policy(policy, None) +# let keypair = tsk.keys().with_policy(policy, None) # .alive().revoked(false).for_signing().nth(0).unwrap() # .key().clone().mark_parts_secret().unwrap().into_keypair()?; # diff --git a/guide/src/chapter_02.md b/guide/src/chapter_02.md index 6f18c59c..ffa0b29b 100644 --- a/guide/src/chapter_02.md +++ b/guide/src/chapter_02.md @@ -56,7 +56,7 @@ fn main() { # -> openpgp::Result<()> { # // Build a vector of recipients to hand to Encryptor. # let mut recipients = -# recipient.keys().set_policy(policy, None).alive().revoked(false) +# recipient.keys().with_policy(policy, None).alive().revoked(false) # .for_transport_encryption() # .map(|ka| ka.key().into()) # .collect::<Vec<_>>(); @@ -133,7 +133,7 @@ fn main() { # where D: FnMut(SymmetricAlgorithm, &SessionKey) -> openpgp::Result<()> # { # // The encryption key is the first and only subkey. -# let key = self.secret.keys().set_policy(self.policy, None) +# let key = self.secret.keys().with_policy(self.policy, None) # .for_transport_encryption().nth(0).unwrap().key().clone(); # # // The secret key is not encrypted. @@ -204,7 +204,7 @@ fn generate() -> openpgp::Result<openpgp::Cert> { # -> openpgp::Result<()> { # // Build a vector of recipients to hand to Encryptor. # let mut recipients = -# recipient.keys().set_policy(policy, None).alive().revoked(false) +# recipient.keys().with_policy(policy, None).alive().revoked(false) # .for_transport_encryption() # .map(|ka| ka.key().into()) # .collect::<Vec<_>>(); @@ -281,7 +281,7 @@ fn generate() -> openpgp::Result<openpgp::Cert> { # where D: FnMut(SymmetricAlgorithm, &SessionKey) -> openpgp::Result<()> # { # // The encryption key is the first and only subkey. -# let key = self.secret.keys().set_policy(self.policy, None) +# let key = self.secret.keys().with_policy(self.policy, None) # .for_transport_encryption().nth(0).unwrap().key().clone(); # # // The secret key is not encrypted. @@ -352,7 +352,7 @@ fn encrypt(policy: &dyn Policy, -> openpgp::Result<()> { // Build a vector of recipients to hand to Encryptor. let mut recipients = - recipient.keys().set_policy(policy, None).alive().revoked(false) + recipient.keys().with_policy(policy, None).alive().revoked(false) .for_transport_encryption() .map(|ka| ka.key().into()) .collect::<Vec<_>>(); @@ -429,7 +429,7 @@ fn encrypt(policy: &dyn Policy, # where D: FnMut(SymmetricAlgorithm, &SessionKey) -> openpgp::Result<()> # { # // The encryption key is the first and only subkey. -# let key = self.secret.keys().set_policy(self.policy, None) +# let key = self.secret.keys().with_policy(self.policy, None) # .for_transport_encryption().nth(0).unwrap().key().clone(); # # // The secret key is not encrypted. @@ -514,7 +514,7 @@ Decrypted data can be read from this using [`io::Read`]. # -> openpgp::Result<()> { # // Build a vector of recipients to hand to Encryptor. # let mut recipients = -# recipient.keys().set_policy(policy, None).alive().revoked(false) +# recipient.keys().with_policy(policy, None).alive().revoked(false) # .for_transport_encryption() # .map(|ka| ka.key().into()) # .collect::<Vec<_>>(); @@ -590,7 +590,7 @@ impl<'a> DecryptionHelper for Helper<'a> { -> openpgp::Result<Option<openpgp::Fingerprint>> where D: FnMut(SymmetricAlgorithm, &SessionKey) -> openpgp::Result<()> { - let key = self.secret.keys().set_policy(self.policy, None) + let key = self.secret.keys().with_policy(self.policy, None) .for_transport_encryption().nth(0).unwrap().key().clone(); // The secret key is not encrypted. diff --git a/ipc/examples/gpg-agent-decrypt.rs b/ipc/examples/gpg-agent-decrypt.rs index 0f0b3beb..853a020c 100644 --- a/ipc/examples/gpg-agent-decrypt.rs +++ b/ipc/examples/gpg-agent-decrypt.rs @@ -80,7 +80,7 @@ impl<'a> Helper<'a> { // Map (sub)KeyIDs to secrets. let mut keys = HashMap::new(); for cert in certs { - for ka in cert.keys().set_policy(policy, None) + for ka in cert.keys().with_policy(policy, None) .for_storage_encryption().for_transport_encryption() { let key = ka.key(); diff --git a/ipc/examples/gpg-agent-sign.rs b/ipc/examples/gpg-agent-sign.rs index 424f2a74..5bad17cd 100644 --- a/ipc/examples/gpg-agent-sign.rs +++ b/ipc/examples/gpg-agent-sign.rs @@ -42,7 +42,7 @@ fn main() { // Construct a KeyPair for every signing-capable (sub)key. let mut signers = certs.iter().flat_map(|cert| { - cert.keys().set_policy(p, None).alive().revoked(false).for_signing() + cert.keys().with_policy(p, None).alive().revoked(false).for_signing() .filter_map(|ka| { KeyPair::new(&ctx, ka.key()).ok() }) diff --git a/ipc/tests/gpg-agent.rs b/ipc/tests/gpg-agent.rs index 909307e1..61fd8ccc 100644 --- a/ipc/tests/gpg-agent.rs +++ b/ipc/tests/gpg-agent.rs @@ -99,7 +99,7 @@ fn sign() { let keypair = KeyPair::new( &ctx, - cert.keys().set_policy(p, None).alive().revoked(false) + cert.keys().with_policy(p, None).alive().revoked(false) .for_signing().take(1).next().unwrap().key()) .unwrap(); @@ -216,7 +216,7 @@ fn decrypt() { let mut message = Vec::new(); { let recipient = - cert.keys().set_policy(p, None).alive().revoked(false) + cert.keys().with_policy(p, None).alive().revoked(false) .for_transport_encryption() .map(|ka| ka.key().into()) .nth(0).unwrap(); @@ -284,7 +284,7 @@ fn decrypt() { { let mut keypair = KeyPair::new( self.ctx, - self.cert.keys().set_policy(self.policy, None) + self.cert.keys().with_policy(self.policy, None) .for_storage_encryption().for_transport_encryption() .take(1).next().unwrap().key()) .unwrap(); diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs index bf11d925..ca8a9cf7 100644 --- a/openpgp-ffi/src/cert.rs +++ b/openpgp-ffi/src/cert.rs @@ -537,7 +537,7 @@ pub extern "C" fn pgp_cert_key_iter_policy<'a>( box_raw!(ValidKeyIterWrapper { iter: unsafe { - std::mem::transmute(tmp.set_policy(&**policy, maybe_time(when))) + std::mem::transmute(tmp.with_policy(&**policy, maybe_time(when))) }, next_called: false, }) diff --git a/openpgp/examples/decrypt-with.rs b/openpgp/examples/decrypt-with.rs index b52c143c..fdcb3f7e 100644 --- a/openpgp/examples/decrypt-with.rs +++ b/openpgp/examples/decrypt-with.rs @@ -62,7 +62,7 @@ impl Helper { // Map (sub)KeyIDs to secrets. let mut keys = HashMap::new(); for cert in certs { - for ka in cert.keys().set_policy(p, None) + for ka in cert.keys().with_policy(p, None) .for_storage_encryption().for_transport_encryption() { // This only works for unencrypted secret keys. diff --git a/openpgp/examples/encrypt-for.rs b/openpgp/examples/encrypt-for.rs index b64165b7..557e648f 100644 --- a/openpgp/examples/encrypt-for.rs +++ b/openpgp/examples/encrypt-for.rs @@ -42,7 +42,7 @@ fn main() { certs.iter() .flat_map(|cert| { cert.keys() - .set_policy(p, None).alive().revoked(false).key_flags(&mode) + .with_policy(p, None).alive().revoked(false).key_flags(&mode) }) .map(|ka| ka.key().into()) .collect::<Vec<_>>(); diff --git a/openpgp/examples/generate-encrypt-decrypt.rs b/openpgp/examples/generate-encrypt-decrypt.rs index 089ed8e7..9f3b8d6a 100644 --- a/openpgp/examples/generate-encrypt-decrypt.rs +++ b/openpgp/examples/generate-encrypt-decrypt.rs @@ -48,7 +48,7 @@ fn encrypt(p: &dyn Policy, sink: &mut dyn Write, plaintext: &str, { // Build a vector of recipients to hand to Encryptor. let mut recipients = - recipient.keys().set_policy(p, None).alive().revoked(false) + recipient.keys().with_policy(p, None).alive().revoked(false) .for_transport_encryption() .map(|ka| ka.key().into()) .collect::<Vec<_>>(); @@ -124,7 +124,7 @@ impl<'a> DecryptionHelper for Helper<'a> { -> openpgp::Result<Option<openpgp::Fingerprint>> where D: FnMut(SymmetricAlgorithm, &SessionKey) -> openpgp::Result<()> { - let key = self.secret.keys().set_policy(self.policy, None) + let key = self.secret.keys().with_policy(self.policy, None) .for_transport_encryption().nth(0).unwrap().key().clone(); // The secret key is not encrypted. diff --git a/openpgp/examples/generate-sign-verify.rs b/openpgp/examples/generate-sign-verify.rs index e3142667..12709609 100644 --- a/openpgp/examples/generate-sign-verify.rs +++ b/openpgp/examples/generate-sign-verify.rs @@ -45,7 +45,7 @@ fn sign(p: &dyn Policy, sink: &mut dyn Write, plaintext: &str, tsk: &openpgp::Ce -> openpgp::Result<()> { // Get the keypair to do the signing from the Cert. let keypair = tsk - .keys().set_policy(p, None).alive().revoked(false).for_signing() + .keys().with_policy(p, None).alive().revoked(false).for_signing() .nth(0).unwrap() .key().clone().mark_parts_secret().unwrap().into_keypair()?; diff --git a/openpgp/examples/notarize.rs b/openpgp/examples/notarize.rs index 62042e60..83e34cee 100644 --- a/openpgp/examples/notarize.rs +++ b/openpgp/examples/notarize.rs @@ -31,7 +31,7 @@ fn main() { let mut n = 0; for key in tsk.keys() - .set_policy(p, None).alive().revoked(false).for_signing().secret() + .with_policy(p, None).alive().revoked(false).for_signing().secret() .map(|ka| ka.key()) { keys.push({ diff --git a/openpgp/examples/pad.rs b/openpgp/examples/pad.rs index 68efa655..c1c341c8 100644 --- a/openpgp/examples/pad.rs +++ b/openpgp/examples/pad.rs @@ -43,7 +43,7 @@ fn main() { .iter() .flat_map(|cert| { cert.keys() - .set_policy(p, None).alive().revoked(false).key_flags(&mode) + .with_policy(p, None).alive().revoked(false).key_flags(&mode) }) .map(|ka| Recipient::new(KeyID::wildcard(), ka.key())) .collect::<Vec<_>>(); diff --git a/openpgp/examples/sign-detached.rs b/openpgp/examples/sign-detached.rs index e93cd0e2..da5cd776 100644 --- a/openpgp/examples/sign-detached.rs +++ b/openpgp/examples/sign-detached.rs @@ -27,7 +27,7 @@ fn main() { let mut n = 0; for key in tsk - .keys().set_policy(p, None).alive().revoked(false).for_signing().secret() + .keys().with_policy(p, None).alive().revoked(false).for_signing().secret() .map(|ka| ka.key()) { keys.push({ diff --git a/openpgp/examples/sign.rs b/openpgp/examples/sign.rs index 85565b2e..95afee20 100644 --- a/openpgp/examples/sign.rs +++ b/openpgp/examples/sign.rs @@ -26,7 +26,7 @@ fn main() { let mut n = 0; for key in tsk.keys() - .set_policy(p, None).alive().revoked(false).for_signing().secret() + .with_policy(p, None).alive().revoked(false).for_signing().secret() .map(|ka| ka.key()) { keys.push({ diff --git a/openpgp/src/autocrypt.rs b/openpgp/src/autocrypt.rs index 22dfa40d..6d02c5ce 100644 --- a/openpgp/src/autocrypt.rs +++ b/openpgp/src/autocrypt.rs @@ -130,7 +130,7 @@ impl AutocryptHeader { } // The UserIDs matching ADDR. - for uidb in cert.userids().set_policy(policy, None) { + for uidb in cert.userids().with_policy(policy, None) { // XXX: Fix match once we have the rfc2822-name-addr. if let Ok(Some(a)) = uidb.userid().email() { if &a == addr { diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs index 10ee8d5b..3ea1b25c 100644 --- a/openpgp/src/cert/amalgamation.rs +++ b/openpgp/src/cert/amalgamation.rs @@ -50,7 +50,7 @@ impl<'a, C> ComponentAmalgamation<'a, C> { /// time, if any. /// /// Note: this function is not exported. Users of this interface - /// should do: ca.set_policy(policy, time)?.binding_signature(). + /// should do: ca.with_policy(policy, time)?.binding_signature(). fn binding_signature<T>(&self, policy: &dyn Policy, time: T) -> Option<&'a Signature> where T: Into<Option<time::SystemTime>> @@ -65,7 +65,7 @@ impl<'a, C> ComponentAmalgamation<'a, C> { /// /// This transforms the `ComponentAmalgamation` into a /// `ValidComponentAmalgamation`. - pub fn set_policy<T>(self, policy: &'a dyn Policy, time: T) + pub fn with_policy<T>(self, policy: &'a dyn Policy, time: T) -> Result<ValidComponentAmalgamation<'a, C>> where T: Into<Option<time::SystemTime>> { @@ -189,7 +189,7 @@ impl<'a, C> ValidComponentAmalgamation<'a, C> } }) .and_then(|c| ComponentAmalgamation::new(cert, (c.0).0) - .set_policy(policy, t).ok()) + .with_policy(policy, t).ok()) } } @@ -213,7 +213,7 @@ pub trait Amalgamation<'a> { /// Changes the amalgamation's policy. /// /// If `time` is `None`, the current time is used. - fn set_policy<T>(self, policy: &'a dyn Policy, time: T) -> Result<Self> + fn with_policy<T>(self, policy: &'a dyn Policy, time: T) -> Result<Self> where Self: Sized, T: Into<Option<time::SystemTime>>; /// Returns the component's binding signature as of the reference time. @@ -272,11 +272,11 @@ impl<'a, C> Amalgamation<'a> for ValidComponentAmalgamation<'a, C> { /// Changes the amalgamation's policy. /// /// If `time` is `None`, the current time is used. - fn set_policy<T>(self, policy: &'a dyn Policy, time: T) -> Result<Self> + fn with_policy<T>(self, policy: &'a dyn Policy, time: T) -> Result<Self> where T: Into<Option<time::SystemTime>> { let time = time.into().unwrap_or_else(SystemTime::now); - self.a.set_policy(policy, time) + self.a. |