summaryrefslogtreecommitdiffstats
path: root/openpgp/src/types
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/src/types')
-rw-r--r--openpgp/src/types/key_flags.rs12
-rw-r--r--openpgp/src/types/server_preferences.rs21
-rw-r--r--openpgp/src/types/timestamp.rs4
3 files changed, 15 insertions, 22 deletions
diff --git a/openpgp/src/types/key_flags.rs b/openpgp/src/types/key_flags.rs
index d8bbf1f3..e25ce6fb 100644
--- a/openpgp/src/types/key_flags.rs
+++ b/openpgp/src/types/key_flags.rs
@@ -50,12 +50,6 @@ use crate::types::Bitfield;
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct KeyFlags(Bitfield);
-impl Default for KeyFlags {
- fn default() -> Self {
- KeyFlags::new(&[])
- }
-}
-
impl fmt::Debug for KeyFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.for_certification() {
@@ -157,7 +151,7 @@ impl KeyFlags {
/// Returns a new `KeyFlags` with all capabilities disabled.
pub fn empty() -> Self {
- KeyFlags::default()
+ KeyFlags::new(&[])
}
/// Returns a slice containing the raw values.
@@ -227,7 +221,7 @@ impl KeyFlags {
/// use openpgp::types::KeyFlags;
///
/// # fn main() -> openpgp::Result<()> {
- /// let kf = KeyFlags::default().set(0).set(2);
+ /// let kf = KeyFlags::empty().set(0).set(2);
///
/// assert!(kf.get(0));
/// assert!(! kf.get(1));
@@ -251,7 +245,7 @@ impl KeyFlags {
/// use openpgp::types::KeyFlags;
///
/// # fn main() -> openpgp::Result<()> {
- /// let kf = KeyFlags::default().set(0).set(2).clear(2);
+ /// let kf = KeyFlags::empty().set(0).set(2).clear(2);
///
/// assert!(kf.get(0));
/// assert!(! kf.get(1));
diff --git a/openpgp/src/types/server_preferences.rs b/openpgp/src/types/server_preferences.rs
index fd462c05..d129ef00 100644
--- a/openpgp/src/types/server_preferences.rs
+++ b/openpgp/src/types/server_preferences.rs
@@ -57,12 +57,6 @@ use crate::types::Bitfield;
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct KeyServerPreferences(Bitfield);
-impl Default for KeyServerPreferences {
- fn default() -> Self {
- KeyServerPreferences::new(&[0])
- }
-}
-
impl fmt::Debug for KeyServerPreferences {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut need_comma = false;
@@ -99,6 +93,11 @@ impl KeyServerPreferences {
KeyServerPreferences(bits.as_ref().to_vec().into())
}
+ /// Returns an empty key server preference set.
+ pub fn empty() -> Self {
+ Self::new(&[])
+ }
+
/// Returns a slice containing the raw values.
pub(crate) fn as_slice(&self) -> &[u8] {
self.0.as_slice()
@@ -166,7 +165,7 @@ impl KeyServerPreferences {
/// use openpgp::types::KeyServerPreferences;
///
/// # fn main() -> openpgp::Result<()> {
- /// let ksp = KeyServerPreferences::default().set(0).set(2);
+ /// let ksp = KeyServerPreferences::empty().set(0).set(2);
///
/// assert!(ksp.get(0));
/// assert!(! ksp.get(1));
@@ -190,7 +189,7 @@ impl KeyServerPreferences {
/// use openpgp::types::KeyServerPreferences;
///
/// # fn main() -> openpgp::Result<()> {
- /// let ksp = KeyServerPreferences::default().set(0).set(2).clear(2);
+ /// let ksp = KeyServerPreferences::empty().set(0).set(2).clear(2);
///
/// assert!(ksp.get(0));
/// assert!(! ksp.get(1));
@@ -217,7 +216,7 @@ impl KeyServerPreferences {
/// use openpgp::types::KeyServerPreferences;
///
/// # fn main() -> openpgp::Result<()> {
- /// let ksp = KeyServerPreferences::default();
+ /// let ksp = KeyServerPreferences::empty();
/// assert!(! ksp.no_modify());
/// # Ok(()) }
/// ```
@@ -238,7 +237,7 @@ impl KeyServerPreferences {
/// use openpgp::types::KeyServerPreferences;
///
/// # fn main() -> openpgp::Result<()> {
- /// let ksp = KeyServerPreferences::default().set_no_modify();
+ /// let ksp = KeyServerPreferences::empty().set_no_modify();
/// assert!(ksp.no_modify());
/// # Ok(()) }
/// ```
@@ -287,7 +286,7 @@ mod tests {
#[test]
fn basics() -> crate::Result<()> {
- let p = KeyServerPreferences::default();
+ let p = KeyServerPreferences::empty();
assert_eq!(p.no_modify(), false);
let p = KeyServerPreferences::new(&[]);
assert_eq!(p.no_modify(), false);
diff --git a/openpgp/src/types/timestamp.rs b/openpgp/src/types/timestamp.rs
index 59b903d1..95cfbfe8 100644
--- a/openpgp/src/types/timestamp.rs
+++ b/openpgp/src/types/timestamp.rs
@@ -185,14 +185,14 @@ impl Timestamp {
/// // Generate a Cert for Alice.
/// let (alice, _) = CertBuilder::new()
/// .set_creation_time(cert_creation_alice)
- /// .set_primary_key_flags(KeyFlags::default().set_certification())
+ /// .set_primary_key_flags(KeyFlags::empty().set_certification())
/// .add_userid("alice@example.org")
/// .generate()?;
///
/// // Generate a Cert for Bob.
/// let (bob, _) = CertBuilder::new()
/// .set_creation_time(cert_creation_bob)
- /// .set_primary_key_flags(KeyFlags::default().set_certification())
+ /// .set_primary_key_flags(KeyFlags::empty().set_certification())
/// .add_userid("bob@example.org")
/// .generate()?;
///