diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-07-03 13:50:00 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-07-18 17:06:52 +0200 |
commit | da25fd9a17f90813f8d7a85d63fe88fa2b2e1ca5 (patch) | |
tree | 1c3be7d5f83a8a9e36aca0cb80a06e0f2daf6f4b /openpgp/src/types | |
parent | 40b77ed618fa93432b3bb4e3ba8a43c5f2e2cb2a (diff) |
openpgp: Use public functions, remove pub(crate) accessors.
Diffstat (limited to 'openpgp/src/types')
-rw-r--r-- | openpgp/src/types/features.rs | 7 | ||||
-rw-r--r-- | openpgp/src/types/key_flags.rs | 17 | ||||
-rw-r--r-- | openpgp/src/types/server_preferences.rs | 7 |
3 files changed, 8 insertions, 23 deletions
diff --git a/openpgp/src/types/features.rs b/openpgp/src/types/features.rs index 65144e25..28fcfba8 100644 --- a/openpgp/src/types/features.rs +++ b/openpgp/src/types/features.rs @@ -153,11 +153,6 @@ impl Features { self.0.normalized_eq(&other.0) } - /// Returns a slice containing the raw values. - pub(crate) fn as_bytes(&self) -> &[u8] { - self.0.as_bytes() - } - /// Returns whether the specified feature flag is set. /// /// # Examples @@ -382,7 +377,7 @@ mod tests { quickcheck! { fn roundtrip(val: Features) -> bool { - let mut q_bytes = val.as_bytes().to_vec(); + let mut q_bytes = val.as_bitfield().as_bytes().to_vec(); let q = Features::new(&q_bytes); assert_eq!(val, q); assert!(val.normalized_eq(&q)); diff --git a/openpgp/src/types/key_flags.rs b/openpgp/src/types/key_flags.rs index aa8f12f0..d6ed335a 100644 --- a/openpgp/src/types/key_flags.rs +++ b/openpgp/src/types/key_flags.rs @@ -108,8 +108,8 @@ impl BitAnd for &KeyFlags { type Output = KeyFlags; fn bitand(self, rhs: Self) -> KeyFlags { - let l = self.as_bytes(); - let r = rhs.as_bytes(); + let l = self.as_bitfield().as_bytes(); + let r = rhs.as_bitfield().as_bytes(); let mut c = Vec::with_capacity(std::cmp::min(l.len(), r.len())); for (l, r) in l.iter().zip(r.iter()) { @@ -124,8 +124,8 @@ impl BitOr for &KeyFlags { type Output = KeyFlags; fn bitor(self, rhs: Self) -> KeyFlags { - let l = self.as_bytes(); - let r = rhs.as_bytes(); + let l = self.as_bitfield().as_bytes(); + let r = rhs.as_bitfield().as_bytes(); // Make l the longer one. let (l, r) = if l.len() > r.len() { @@ -170,11 +170,6 @@ impl KeyFlags { &mut self.0 } - /// Returns a slice containing the raw values. - pub(crate) fn as_bytes(&self) -> &[u8] { - self.0.as_bytes() - } - /// Compares two key flag sets for semantic equality. /// /// `KeyFlags`' implementation of `PartialEq` compares two key @@ -456,7 +451,7 @@ impl KeyFlags { /// Returns whether no flags are set. pub fn is_empty(&self) -> bool { - self.as_bytes().iter().all(|b| *b == 0) + self.as_bitfield().as_bytes().iter().all(|b| *b == 0) } } @@ -496,7 +491,7 @@ mod tests { quickcheck! { fn roundtrip(val: KeyFlags) -> bool { - let mut q_bytes = val.as_bytes().to_vec(); + let mut q_bytes = val.as_bitfield().as_bytes().to_vec(); let q = KeyFlags::new(&q_bytes); assert_eq!(val, q); assert!(val.normalized_eq(&q)); diff --git a/openpgp/src/types/server_preferences.rs b/openpgp/src/types/server_preferences.rs index ef989bf6..f5e8a690 100644 --- a/openpgp/src/types/server_preferences.rs +++ b/openpgp/src/types/server_preferences.rs @@ -108,11 +108,6 @@ impl KeyServerPreferences { &mut self.0 } - /// Returns a slice containing the raw values. - pub(crate) fn as_bytes(&self) -> &[u8] { - self.0.as_bytes() - } - /// Compares two key server preference sets for semantic equality. /// /// `KeyServerPreferences`' implementation of `PartialEq` compares @@ -311,7 +306,7 @@ mod tests { quickcheck! { fn roundtrip(val: KeyServerPreferences) -> bool { - let mut q_bytes = val.as_bytes().to_vec(); + let mut q_bytes = val.as_bitfield().as_bytes().to_vec(); let q = KeyServerPreferences::new(&q_bytes); assert_eq!(val, q); assert!(val.normalized_eq(&q)); |