diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-07-03 11:44:00 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-07-18 16:41:15 +0200 |
commit | 430dcbf562d97b58dfa564d7037c9218df253626 (patch) | |
tree | c8a1bd1753b1f32811d422529ad86419a6d4d7db /openpgp/src/types | |
parent | 122cdd7c624314651a6c953530bd5204e1996ef0 (diff) |
openpgp: Rename accessors for the raw bytes.
Diffstat (limited to 'openpgp/src/types')
-rw-r--r-- | openpgp/src/types/bitfield.rs | 4 | ||||
-rw-r--r-- | openpgp/src/types/features.rs | 6 | ||||
-rw-r--r-- | openpgp/src/types/key_flags.rs | 16 | ||||
-rw-r--r-- | openpgp/src/types/server_preferences.rs | 6 |
4 files changed, 16 insertions, 16 deletions
diff --git a/openpgp/src/types/bitfield.rs b/openpgp/src/types/bitfield.rs index dea6439a..6df0791a 100644 --- a/openpgp/src/types/bitfield.rs +++ b/openpgp/src/types/bitfield.rs @@ -59,12 +59,12 @@ impl Bitfield { } /// Returns a slice containing the raw values. - pub(crate) fn as_slice(&self) -> &[u8] { + pub fn as_bytes(&self) -> &[u8] { &self.raw } /// Returns a slice containing the raw values. - pub(crate) fn as_slice_mut(&mut self) -> &mut [u8] { + pub fn as_bytes_mut(&mut self) -> &mut [u8] { &mut self.raw } diff --git a/openpgp/src/types/features.rs b/openpgp/src/types/features.rs index c77d9f85..b085a000 100644 --- a/openpgp/src/types/features.rs +++ b/openpgp/src/types/features.rs @@ -145,8 +145,8 @@ impl Features { } /// Returns a slice containing the raw values. - pub(crate) fn as_slice(&self) -> &[u8] { - self.0.as_slice() + pub(crate) fn as_bytes(&self) -> &[u8] { + self.0.as_bytes() } /// Returns whether the specified feature flag is set. @@ -369,7 +369,7 @@ mod tests { quickcheck! { fn roundtrip(val: Features) -> bool { - let mut q_bytes = val.as_slice().to_vec(); + let mut q_bytes = val.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 c2f3e62a..a71cff03 100644 --- a/openpgp/src/types/key_flags.rs +++ b/openpgp/src/types/key_flags.rs @@ -109,8 +109,8 @@ impl BitAnd for &KeyFlags { type Output = KeyFlags; fn bitand(self, rhs: Self) -> KeyFlags { - let l = self.as_slice(); - let r = rhs.as_slice(); + let l = self.as_bytes(); + let r = rhs.as_bytes(); let mut c = Vec::with_capacity(std::cmp::min(l.len(), r.len())); for (l, r) in l.iter().zip(r.iter()) { @@ -125,8 +125,8 @@ impl BitOr for &KeyFlags { type Output = KeyFlags; fn bitor(self, rhs: Self) -> KeyFlags { - let l = self.as_slice(); - let r = rhs.as_slice(); + let l = self.as_bytes(); + let r = rhs.as_bytes(); // Make l the longer one. let (l, r) = if l.len() > r.len() { @@ -162,8 +162,8 @@ impl KeyFlags { } /// Returns a slice containing the raw values. - pub(crate) fn as_slice(&self) -> &[u8] { - self.0.as_slice() + pub(crate) fn as_bytes(&self) -> &[u8] { + self.0.as_bytes() } /// Compares two key flag sets for semantic equality. @@ -443,7 +443,7 @@ impl KeyFlags { /// Returns whether no flags are set. pub fn is_empty(&self) -> bool { - self.as_slice().iter().all(|b| *b == 0) + self.as_bytes().iter().all(|b| *b == 0) } } @@ -483,7 +483,7 @@ mod tests { quickcheck! { fn roundtrip(val: KeyFlags) -> bool { - let mut q_bytes = val.as_slice().to_vec(); + let mut q_bytes = val.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 faa1ae4a..4708fd3c 100644 --- a/openpgp/src/types/server_preferences.rs +++ b/openpgp/src/types/server_preferences.rs @@ -100,8 +100,8 @@ impl KeyServerPreferences { } /// Returns a slice containing the raw values. - pub(crate) fn as_slice(&self) -> &[u8] { - self.0.as_slice() + pub(crate) fn as_bytes(&self) -> &[u8] { + self.0.as_bytes() } /// Compares two key server preference sets for semantic equality. @@ -298,7 +298,7 @@ mod tests { quickcheck! { fn roundtrip(val: KeyServerPreferences) -> bool { - let mut q_bytes = val.as_slice().to_vec(); + let mut q_bytes = val.as_bytes().to_vec(); let q = KeyServerPreferences::new(&q_bytes); assert_eq!(val, q); assert!(val.normalized_eq(&q)); |