File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 66
77### Features
88
9+ - (` ark-serialize ` ) Implementation of ` CanonicalSerialize ` and ` CanonicalDeserialize ` for signed integer types
10+
911### Improvements
1012
1113### Bugfixes
Original file line number Diff line number Diff line change @@ -103,6 +103,10 @@ impl_uint!(u8);
103103impl_uint ! ( u16 ) ;
104104impl_uint ! ( u32 ) ;
105105impl_uint ! ( u64 ) ;
106+ impl_uint ! ( i8 ) ;
107+ impl_uint ! ( i16 ) ;
108+ impl_uint ! ( i32 ) ;
109+ impl_uint ! ( i64 ) ;
106110
107111impl CanonicalSerialize for usize {
108112 #[ inline]
@@ -148,6 +152,50 @@ impl CanonicalDeserialize for usize {
148152 }
149153}
150154
155+ impl CanonicalSerialize for isize {
156+ #[ inline]
157+ fn serialize_with_mode < W : Write > (
158+ & self ,
159+ mut writer : W ,
160+ _compress : Compress ,
161+ ) -> Result < ( ) , SerializationError > {
162+ Ok ( writer. write_all ( & ( * self as i64 ) . to_le_bytes ( ) ) ?)
163+ }
164+
165+ #[ inline]
166+ fn serialized_size ( & self , _compress : Compress ) -> usize {
167+ core:: mem:: size_of :: < i64 > ( )
168+ }
169+ }
170+
171+ impl Valid for isize {
172+ #[ inline]
173+ fn check ( & self ) -> Result < ( ) , SerializationError > {
174+ Ok ( ( ) )
175+ }
176+
177+ #[ inline]
178+ fn batch_check < ' a > ( _batch : impl Iterator < Item = & ' a Self > ) -> Result < ( ) , SerializationError >
179+ where
180+ Self : ' a ,
181+ {
182+ Ok ( ( ) )
183+ }
184+ }
185+
186+ impl CanonicalDeserialize for isize {
187+ #[ inline]
188+ fn deserialize_with_mode < R : Read > (
189+ mut reader : R ,
190+ _compress : Compress ,
191+ _validate : Validate ,
192+ ) -> Result < Self , SerializationError > {
193+ let mut bytes = [ 0u8 ; core:: mem:: size_of :: < i64 > ( ) ] ;
194+ reader. read_exact ( & mut bytes) ?;
195+ Ok ( <i64 >:: from_le_bytes ( bytes) as Self )
196+ }
197+ }
198+
151199impl CanonicalSerialize for BigUint {
152200 #[ inline]
153201 fn serialize_with_mode < W : Write > (
You can’t perform that action at this time.
0 commit comments