Struct sequoia_openpgp::types::KeyServerPreferences
source · [−]pub struct KeyServerPreferences(_);
Expand description
Describes preferences regarding key servers.
Key server preferences are specified in Section 5.2.3.17 of RFC 4880 and Section 5.2.3.18 of RFC 4880bis.
The keyserver preferences are set by the user’s OpenPGP implementation to communicate them to any peers.
A note on equality
PartialEq
compares the serialized form of the two key server
preference sets. If you prefer to compare two key server
preference sets for semantic equality, you should use
KeyServerPreferences::normalized_eq
. The difference between
semantic equality and serialized equality is that semantic
equality ignores differences in the amount of padding.
Examples
use sequoia_openpgp as openpgp;
use openpgp::cert::prelude::*;
use openpgp::policy::StandardPolicy;
let p = &StandardPolicy::new();
let (cert, _) =
CertBuilder::general_purpose(None, Some("alice@example.org"))
.generate()?;
match cert.with_policy(p, None)?.primary_userid()?.key_server_preferences() {
Some(preferences) => {
println!("Certificate holder's keyserver preferences:");
assert!(preferences.no_modify());
}
None => {
println!("Certificate Holder did not specify any key server preferences.");
}
}
Implementations
sourceimpl KeyServerPreferences
impl KeyServerPreferences
sourcepub fn as_bitfield(&self) -> &Bitfield
pub fn as_bitfield(&self) -> &Bitfield
Returns a reference to the underlying Bitfield
.
sourcepub fn as_bitfield_mut(&mut self) -> &mut Bitfield
pub fn as_bitfield_mut(&mut self) -> &mut Bitfield
Returns a mutable reference to the underlying Bitfield
.
sourcepub fn normalized_eq(&self, other: &Self) -> bool
pub fn normalized_eq(&self, other: &Self) -> bool
Compares two key server preference sets for semantic equality.
KeyServerPreferences
’ implementation of PartialEq
compares
two key server preference sets for serialized equality. That
is, the PartialEq
implementation considers two key server
preference sets to not be equal if they have different
amounts of padding. This comparison function ignores padding.
Examples
use sequoia_openpgp as openpgp;
use openpgp::types::KeyServerPreferences;
let a = KeyServerPreferences::new(&[0x1]);
let b = KeyServerPreferences::new(&[0x1, 0x0]);
assert!(a != b);
assert!(a.normalized_eq(&b));
sourcepub fn get(&self, bit: usize) -> bool
pub fn get(&self, bit: usize) -> bool
Returns whether the specified keyserver preference flag is set.
Examples
use sequoia_openpgp as openpgp;
use openpgp::types::KeyServerPreferences;
// Keyserver Preferences flags 0 and 2.
let ksp = KeyServerPreferences::new(&[0x5]);
assert!(ksp.get(0));
assert!(! ksp.get(1));
assert!(ksp.get(2));
assert!(! ksp.get(3));
assert!(! ksp.get(8));
assert!(! ksp.get(80));
sourcepub fn set(self, bit: usize) -> Self
pub fn set(self, bit: usize) -> Self
Sets the specified keyserver preference flag.
This also clears any padding (trailing NUL bytes).
Examples
use sequoia_openpgp as openpgp;
use openpgp::types::KeyServerPreferences;
let ksp = KeyServerPreferences::empty().set(0).set(2);
assert!(ksp.get(0));
assert!(! ksp.get(1));
assert!(ksp.get(2));
assert!(! ksp.get(3));
sourcepub fn clear(self, bit: usize) -> Self
pub fn clear(self, bit: usize) -> Self
Clears the specified keyserver preference flag.
This also clears any padding (trailing NUL bytes).
Examples
use sequoia_openpgp as openpgp;
use openpgp::types::KeyServerPreferences;
let ksp = KeyServerPreferences::empty().set(0).set(2).clear(2);
assert!(ksp.get(0));
assert!(! ksp.get(1));
assert!(! ksp.get(2));
assert!(! ksp.get(3));
sourcepub fn no_modify(&self) -> bool
pub fn no_modify(&self) -> bool
Returns whether the certificate’s owner requests that the certificate is not modified.
If this flag is set, the certificate’s owner requests that the certificate should only be changed by the owner and the key server’s operator.
Examples
use sequoia_openpgp as openpgp;
use openpgp::types::KeyServerPreferences;
let ksp = KeyServerPreferences::empty();
assert!(! ksp.no_modify());
sourcepub fn set_no_modify(self) -> Self
pub fn set_no_modify(self) -> Self
Requests that the certificate is not modified.
See KeyServerPreferences::no_modify
.
Examples
use sequoia_openpgp as openpgp;
use openpgp::types::KeyServerPreferences;
let ksp = KeyServerPreferences::empty().set_no_modify();
assert!(ksp.no_modify());
sourcepub fn clear_no_modify(self) -> Self
pub fn clear_no_modify(self) -> Self
Clears the request that the certificate is not modified.
See KeyServerPreferences::no_modify
.
Examples
use sequoia_openpgp as openpgp;
use openpgp::types::KeyServerPreferences;
let ksp = KeyServerPreferences::new(&[0x80][..]);
assert!(ksp.no_modify());
let ksp = ksp.clear_no_modify();
assert!(! ksp.no_modify());
Trait Implementations
sourceimpl Clone for KeyServerPreferences
impl Clone for KeyServerPreferences
sourcefn clone(&self) -> KeyServerPreferences
fn clone(&self) -> KeyServerPreferences
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for KeyServerPreferences
impl Debug for KeyServerPreferences
sourceimpl Hash for KeyServerPreferences
impl Hash for KeyServerPreferences
sourceimpl Ord for KeyServerPreferences
impl Ord for KeyServerPreferences
sourceimpl PartialEq<KeyServerPreferences> for KeyServerPreferences
impl PartialEq<KeyServerPreferences> for KeyServerPreferences
sourcefn eq(&self, other: &KeyServerPreferences) -> bool
fn eq(&self, other: &KeyServerPreferences) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &KeyServerPreferences) -> bool
fn ne(&self, other: &KeyServerPreferences) -> bool
This method tests for !=
.
sourceimpl PartialOrd<KeyServerPreferences> for KeyServerPreferences
impl PartialOrd<KeyServerPreferences> for KeyServerPreferences
sourcefn partial_cmp(&self, other: &KeyServerPreferences) -> Option<Ordering>
fn partial_cmp(&self, other: &KeyServerPreferences) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for KeyServerPreferences
impl StructuralEq for KeyServerPreferences
impl StructuralPartialEq for KeyServerPreferences
Auto Trait Implementations
impl RefUnwindSafe for KeyServerPreferences
impl Send for KeyServerPreferences
impl Sync for KeyServerPreferences
impl Unpin for KeyServerPreferences
impl UnwindSafe for KeyServerPreferences
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more