[−][src]Struct sequoia_openpgp::types::Features
Describes the features supported by an OpenPGP implementation.
The feature flags are defined in Section 5.2.3.24 of RFC 4880, and Section 5.2.3.25 of RFC 4880bis.
The feature flags are set by the user's OpenPGP implementation to signal to any senders what features the implementation supports.
A note on equality
PartialEq
compares the serialized form of the two feature sets.
If you prefer to compare two feature sets for semantic equality,
you should use Features::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(); match cert.with_policy(p, None)?.primary_userid()?.features() { Some(features) => { println!("Certificate holder's supported features:"); assert!(features.supports_mdc()); assert!(!features.supports_aead()); } None => { println!("Certificate Holder did not specify any features."); } }
Implementations
impl Features
[src]
pub fn new<B>(bytes: B) -> Self where
B: AsRef<[u8]>,
[src]
B: AsRef<[u8]>,
Creates a new instance from bytes
.
This does not remove any trailing padding from bytes
.
pub fn empty() -> Self
[src]
Returns an empty feature set.
pub fn sequoia() -> Self
[src]
Returns a feature set describing Sequoia's capabilities.
pub fn normalized_eq(&self, other: &Self) -> bool
[src]
Compares two feature sets for semantic equality.
Features
' implementation of PartialEq
compares two feature
sets for serialized equality. That is, the PartialEq
implementation considers two feature 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::Features; let a = Features::new(&[0x1]); let b = Features::new(&[0x1, 0x0]); assert!(a != b); assert!(a.normalized_eq(&b));
pub fn get(&self, bit: usize) -> bool
[src]
Returns whether the specified feature flag is set.
Examples
use sequoia_openpgp as openpgp; use openpgp::types::Features; // Feature flags 0 and 2. let f = Features::new(&[0x5]); assert!(f.get(0)); assert!(! f.get(1)); assert!(f.get(2)); assert!(! f.get(3)); assert!(! f.get(8)); assert!(! f.get(80));
pub fn set(self, bit: usize) -> Self
[src]
Sets the specified feature flag.
This also clears any padding (trailing NUL bytes).
Examples
use sequoia_openpgp as openpgp; use openpgp::types::Features; let f = Features::empty().set(0).set(2); assert!(f.get(0)); assert!(! f.get(1)); assert!(f.get(2)); assert!(! f.get(3));
pub fn clear(self, bit: usize) -> Self
[src]
Clears the specified feature flag.
This also clears any padding (trailing NUL bytes).
Examples
use sequoia_openpgp as openpgp; use openpgp::types::Features; let f = Features::empty().set(0).set(2).clear(2); assert!(f.get(0)); assert!(! f.get(1)); assert!(! f.get(2)); assert!(! f.get(3));
pub fn supports_mdc(&self) -> bool
[src]
Returns whether the MDC feature flag is set.
Examples
use sequoia_openpgp as openpgp; use openpgp::types::Features; let f = Features::empty(); assert!(! f.supports_mdc());
pub fn set_mdc(self) -> Self
[src]
Sets the MDC feature flag.
Examples
use sequoia_openpgp as openpgp; use openpgp::types::Features; let f = Features::empty().set_mdc(); assert!(f.supports_mdc());
pub fn clear_mdc(self) -> Self
[src]
Clears the MDC feature flag.
Examples
use sequoia_openpgp as openpgp; use openpgp::types::Features; let f = Features::new(&[0x1]); assert!(f.supports_mdc()); let f = f.clear_mdc(); assert!(! f.supports_mdc());
pub fn supports_aead(&self) -> bool
[src]
Returns whether the AEAD feature flag is set.
Examples
use sequoia_openpgp as openpgp; use openpgp::types::Features; let f = Features::empty(); assert!(! f.supports_aead());
pub fn set_aead(self) -> Self
[src]
Sets the AEAD feature flag.
Examples
use sequoia_openpgp as openpgp; use openpgp::types::Features; let f = Features::empty().set_aead(); assert!(f.supports_aead());
pub fn clear_aead(self) -> Self
[src]
Clears the AEAD feature flag.
Examples
use sequoia_openpgp as openpgp; use openpgp::types::Features; let f = Features::new(&[0x2]); assert!(f.supports_aead()); let f = f.clear_aead(); assert!(! f.supports_aead());
Trait Implementations
impl Clone for Features
[src]
impl Debug for Features
[src]
impl Eq for Features
[src]
impl Hash for Features
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Features
[src]
pub fn cmp(&self, other: &Features) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Features> for Features
[src]
impl PartialOrd<Features> for Features
[src]
pub fn partial_cmp(&self, other: &Features) -> Option<Ordering>
[src]
pub fn lt(&self, other: &Features) -> bool
[src]
pub fn le(&self, other: &Features) -> bool
[src]
pub fn gt(&self, other: &Features) -> bool
[src]
pub fn ge(&self, other: &Features) -> bool
[src]
impl StructuralEq for Features
[src]
impl StructuralPartialEq for Features
[src]
Auto Trait Implementations
impl RefUnwindSafe for Features
[src]
impl Send for Features
[src]
impl Sync for Features
[src]
impl Unpin for Features
[src]
impl UnwindSafe for Features
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,