@@ -14,13 +14,13 @@ use crate::{
1414/// Intended for use cases like very large integers that are used in
1515/// cryptographic applications (e.g. keys, signatures).
1616#[ derive( Copy , Clone , Debug , Eq , PartialEq , PartialOrd , Ord ) ]
17- pub struct UIntRef < ' a > {
17+ pub struct UintRef < ' a > {
1818 /// Inner value
1919 inner : ByteSlice < ' a > ,
2020}
2121
22- impl < ' a > UIntRef < ' a > {
23- /// Create a new [`UIntRef `] from a byte slice.
22+ impl < ' a > UintRef < ' a > {
23+ /// Create a new [`UintRef `] from a byte slice.
2424 pub fn new ( bytes : & ' a [ u8 ] ) -> Result < Self > {
2525 let inner = ByteSlice :: new ( uint:: strip_leading_zeroes ( bytes) )
2626 . map_err ( |_| ErrorKind :: Length { tag : Self :: TAG } ) ?;
@@ -34,7 +34,7 @@ impl<'a> UIntRef<'a> {
3434 self . inner . as_slice ( )
3535 }
3636
37- /// Get the length of this [`UIntRef `] in bytes.
37+ /// Get the length of this [`UintRef `] in bytes.
3838 pub fn len ( & self ) -> Length {
3939 self . inner . len ( )
4040 }
@@ -45,7 +45,7 @@ impl<'a> UIntRef<'a> {
4545 }
4646}
4747
48- impl < ' a > DecodeValue < ' a > for UIntRef < ' a > {
48+ impl < ' a > DecodeValue < ' a > for UintRef < ' a > {
4949 fn decode_value < R : Reader < ' a > > ( reader : & mut R , header : Header ) -> Result < Self > {
5050 let bytes = ByteSlice :: decode_value ( reader, header) ?. as_slice ( ) ;
5151 let result = Self :: new ( uint:: decode_to_slice ( bytes) ?) ?;
@@ -59,7 +59,7 @@ impl<'a> DecodeValue<'a> for UIntRef<'a> {
5959 }
6060}
6161
62- impl < ' a > EncodeValue for UIntRef < ' a > {
62+ impl < ' a > EncodeValue for UintRef < ' a > {
6363 fn value_len ( & self ) -> Result < Length > {
6464 uint:: encoded_len ( self . inner . as_slice ( ) )
6565 }
@@ -74,49 +74,49 @@ impl<'a> EncodeValue for UIntRef<'a> {
7474 }
7575}
7676
77- impl < ' a > From < & UIntRef < ' a > > for UIntRef < ' a > {
78- fn from ( value : & UIntRef < ' a > ) -> UIntRef < ' a > {
77+ impl < ' a > From < & UintRef < ' a > > for UintRef < ' a > {
78+ fn from ( value : & UintRef < ' a > ) -> UintRef < ' a > {
7979 * value
8080 }
8181}
8282
83- impl < ' a > TryFrom < AnyRef < ' a > > for UIntRef < ' a > {
83+ impl < ' a > TryFrom < AnyRef < ' a > > for UintRef < ' a > {
8484 type Error = Error ;
8585
86- fn try_from ( any : AnyRef < ' a > ) -> Result < UIntRef < ' a > > {
86+ fn try_from ( any : AnyRef < ' a > ) -> Result < UintRef < ' a > > {
8787 any. decode_into ( )
8888 }
8989}
9090
91- impl < ' a > FixedTag for UIntRef < ' a > {
91+ impl < ' a > FixedTag for UintRef < ' a > {
9292 const TAG : Tag = Tag :: Integer ;
9393}
9494
95- impl < ' a > OrdIsValueOrd for UIntRef < ' a > { }
95+ impl < ' a > OrdIsValueOrd for UintRef < ' a > { }
9696
9797#[ cfg( test) ]
9898mod tests {
99- use super :: UIntRef ;
99+ use super :: UintRef ;
100100 use crate :: {
101101 asn1:: { integer:: tests:: * , AnyRef } ,
102102 Decode , Encode , ErrorKind , SliceWriter , Tag ,
103103 } ;
104104
105105 #[ test]
106106 fn decode_uint_bytes ( ) {
107- assert_eq ! ( & [ 0 ] , UIntRef :: from_der( I0_BYTES ) . unwrap( ) . as_bytes( ) ) ;
108- assert_eq ! ( & [ 127 ] , UIntRef :: from_der( I127_BYTES ) . unwrap( ) . as_bytes( ) ) ;
109- assert_eq ! ( & [ 128 ] , UIntRef :: from_der( I128_BYTES ) . unwrap( ) . as_bytes( ) ) ;
110- assert_eq ! ( & [ 255 ] , UIntRef :: from_der( I255_BYTES ) . unwrap( ) . as_bytes( ) ) ;
107+ assert_eq ! ( & [ 0 ] , UintRef :: from_der( I0_BYTES ) . unwrap( ) . as_bytes( ) ) ;
108+ assert_eq ! ( & [ 127 ] , UintRef :: from_der( I127_BYTES ) . unwrap( ) . as_bytes( ) ) ;
109+ assert_eq ! ( & [ 128 ] , UintRef :: from_der( I128_BYTES ) . unwrap( ) . as_bytes( ) ) ;
110+ assert_eq ! ( & [ 255 ] , UintRef :: from_der( I255_BYTES ) . unwrap( ) . as_bytes( ) ) ;
111111
112112 assert_eq ! (
113113 & [ 0x01 , 0x00 ] ,
114- UIntRef :: from_der( I256_BYTES ) . unwrap( ) . as_bytes( )
114+ UintRef :: from_der( I256_BYTES ) . unwrap( ) . as_bytes( )
115115 ) ;
116116
117117 assert_eq ! (
118118 & [ 0x7F , 0xFF ] ,
119- UIntRef :: from_der( I32767_BYTES ) . unwrap( ) . as_bytes( )
119+ UintRef :: from_der( I32767_BYTES ) . unwrap( ) . as_bytes( )
120120 ) ;
121121 }
122122
@@ -130,7 +130,7 @@ mod tests {
130130 I256_BYTES ,
131131 I32767_BYTES ,
132132 ] {
133- let uint = UIntRef :: from_der ( example) . unwrap ( ) ;
133+ let uint = UintRef :: from_der ( example) . unwrap ( ) ;
134134
135135 let mut buf = [ 0u8 ; 128 ] ;
136136 let mut encoder = SliceWriter :: new ( & mut buf) ;
@@ -143,7 +143,7 @@ mod tests {
143143
144144 #[ test]
145145 fn reject_oversize_without_extra_zero ( ) {
146- let err = UIntRef :: try_from ( AnyRef :: new ( Tag :: Integer , & [ 0x81 ] ) . unwrap ( ) )
146+ let err = UintRef :: try_from ( AnyRef :: new ( Tag :: Integer , & [ 0x81 ] ) . unwrap ( ) )
147147 . err ( )
148148 . unwrap ( ) ;
149149
0 commit comments