summaryrefslogtreecommitdiffstats
path: root/third_party/rust/prio/src/field/field255.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/prio/src/field/field255.rs
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/prio/src/field/field255.rs')
-rw-r--r--third_party/rust/prio/src/field/field255.rs31
1 files changed, 23 insertions, 8 deletions
diff --git a/third_party/rust/prio/src/field/field255.rs b/third_party/rust/prio/src/field/field255.rs
index fd06a6334a..15a53f8b09 100644
--- a/third_party/rust/prio/src/field/field255.rs
+++ b/third_party/rust/prio/src/field/field255.rs
@@ -271,8 +271,9 @@ impl<'de> Deserialize<'de> for Field255 {
}
impl Encode for Field255 {
- fn encode(&self, bytes: &mut Vec<u8>) {
+ fn encode(&self, bytes: &mut Vec<u8>) -> Result<(), CodecError> {
bytes.extend_from_slice(&<[u8; Self::ENCODED_SIZE]>::from(*self));
+ Ok(())
}
fn encoded_len(&self) -> Option<usize> {
@@ -341,7 +342,7 @@ mod tests {
codec::Encode,
field::{
test_utils::{field_element_test_common, TestFieldElementWithInteger},
- FieldElement, FieldError,
+ FieldElement, FieldError, Integer,
},
};
use assert_matches::assert_matches;
@@ -375,16 +376,30 @@ mod tests {
}
}
+ impl Integer for BigUint {
+ type TryFromUsizeError = <Self as TryFrom<usize>>::Error;
+
+ type TryIntoU64Error = <Self as TryInto<u64>>::Error;
+
+ fn zero() -> Self {
+ Self::new(Vec::new())
+ }
+
+ fn one() -> Self {
+ Self::new(Vec::from([1]))
+ }
+ }
+
impl TestFieldElementWithInteger for Field255 {
- type Integer = BigUint;
- type IntegerTryFromError = <Self::Integer as TryFrom<usize>>::Error;
- type TryIntoU64Error = <Self::Integer as TryInto<u64>>::Error;
+ type TestInteger = BigUint;
+ type IntegerTryFromError = <Self::TestInteger as TryFrom<usize>>::Error;
+ type TryIntoU64Error = <Self::TestInteger as TryInto<u64>>::Error;
- fn pow(&self, _exp: Self::Integer) -> Self {
+ fn pow(&self, _exp: Self::TestInteger) -> Self {
unimplemented!("Field255::pow() is not implemented because it's not needed yet")
}
- fn modulus() -> Self::Integer {
+ fn modulus() -> Self::TestInteger {
MODULUS.clone()
}
}
@@ -415,7 +430,7 @@ mod tests {
#[test]
fn encode_endianness() {
let mut one_encoded = Vec::new();
- Field255::one().encode(&mut one_encoded);
+ Field255::one().encode(&mut one_encoded).unwrap();
assert_eq!(
one_encoded,
[