Skip to content

Commit ad7bf4f

Browse files
committed
chore: Merge branch 'release/v10.2.0'
2 parents d689ea3 + 456a35c commit ad7bf4f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/bytes_ser_de.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{
55
fmt::Debug,
66
hash::Hash,
77
io::{Read, Write},
8+
num::NonZeroUsize,
89
};
910

1011
use leb128;
@@ -334,6 +335,26 @@ impl Serializable for usize {
334335
}
335336
}
336337

338+
impl Serializable for NonZeroUsize {
339+
type Error = CryptoCoreError;
340+
341+
fn length(&self) -> usize {
342+
self.get().length()
343+
}
344+
345+
fn write(&self, ser: &mut Serializer) -> Result<usize, Self::Error> {
346+
self.get().write(ser)
347+
}
348+
349+
fn read(de: &mut Deserializer) -> Result<Self, Self::Error> {
350+
Self::new(de.read()?).ok_or_else(|| {
351+
Self::Error::GenericDeserializationError(
352+
"null value read while a non-zero value was expected".to_string(),
353+
)
354+
})
355+
}
356+
}
357+
337358
impl Serializable for String {
338359
type Error = CryptoCoreError;
339360

0 commit comments

Comments
 (0)