Struct sequoia_openpgp::types::KeyServerPreferences[][src]

pub struct KeyServerPreferences(_);

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

impl KeyServerPreferences[src]

pub fn new<B: AsRef<[u8]>>(bits: B) -> Self[src]

Creates a new instance from bits.

pub fn empty() -> Self[src]

Returns an empty key server preference set.

pub fn normalized_eq(&self, other: &Self) -> bool[src]

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));

pub fn get(&self, bit: usize) -> bool[src]

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));

pub fn set(self, bit: usize) -> Self[src]

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));

pub fn clear(self, bit: usize) -> Self[src]

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));

pub fn no_modify(&self) -> bool[src]

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());

pub fn set_no_modify(self) -> Self[src]

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());

pub fn clear_no_modify(self) -> Self[src]

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

impl Clone for KeyServerPreferences[src]

fn clone(&self) -> KeyServerPreferences[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for KeyServerPreferences[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Hash for KeyServerPreferences[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl Ord for KeyServerPreferences[src]

fn cmp(&self, other: &KeyServerPreferences) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<KeyServerPreferences> for KeyServerPreferences[src]

fn eq(&self, other: &KeyServerPreferences) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &KeyServerPreferences) -> bool[src]

This method tests for !=.

impl PartialOrd<KeyServerPreferences> for KeyServerPreferences[src]

fn partial_cmp(&self, other: &KeyServerPreferences) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Eq for KeyServerPreferences[src]

impl StructuralEq for KeyServerPreferences[src]

impl StructuralPartialEq for KeyServerPreferences[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> DynClone for T where
    T: Clone
[src]

pub fn __clone_box(&self, Private) -> *mut ()[src]

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.