@@ -14,13 +14,13 @@ use crate::{
14
14
/// Intended for use cases like very large integers that are used in
15
15
/// cryptographic applications (e.g. keys, signatures).
16
16
#[ derive( Copy , Clone , Debug , Eq , PartialEq , PartialOrd , Ord ) ]
17
- pub struct UIntRef < ' a > {
17
+ pub struct UintRef < ' a > {
18
18
/// Inner value
19
19
inner : ByteSlice < ' a > ,
20
20
}
21
21
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.
24
24
pub fn new ( bytes : & ' a [ u8 ] ) -> Result < Self > {
25
25
let inner = ByteSlice :: new ( uint:: strip_leading_zeroes ( bytes) )
26
26
. map_err ( |_| ErrorKind :: Length { tag : Self :: TAG } ) ?;
@@ -34,7 +34,7 @@ impl<'a> UIntRef<'a> {
34
34
self . inner . as_slice ( )
35
35
}
36
36
37
- /// Get the length of this [`UIntRef `] in bytes.
37
+ /// Get the length of this [`UintRef `] in bytes.
38
38
pub fn len ( & self ) -> Length {
39
39
self . inner . len ( )
40
40
}
@@ -45,7 +45,7 @@ impl<'a> UIntRef<'a> {
45
45
}
46
46
}
47
47
48
- impl < ' a > DecodeValue < ' a > for UIntRef < ' a > {
48
+ impl < ' a > DecodeValue < ' a > for UintRef < ' a > {
49
49
fn decode_value < R : Reader < ' a > > ( reader : & mut R , header : Header ) -> Result < Self > {
50
50
let bytes = ByteSlice :: decode_value ( reader, header) ?. as_slice ( ) ;
51
51
let result = Self :: new ( uint:: decode_to_slice ( bytes) ?) ?;
@@ -59,7 +59,7 @@ impl<'a> DecodeValue<'a> for UIntRef<'a> {
59
59
}
60
60
}
61
61
62
- impl < ' a > EncodeValue for UIntRef < ' a > {
62
+ impl < ' a > EncodeValue for UintRef < ' a > {
63
63
fn value_len ( & self ) -> Result < Length > {
64
64
uint:: encoded_len ( self . inner . as_slice ( ) )
65
65
}
@@ -74,49 +74,49 @@ impl<'a> EncodeValue for UIntRef<'a> {
74
74
}
75
75
}
76
76
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 > {
79
79
* value
80
80
}
81
81
}
82
82
83
- impl < ' a > TryFrom < AnyRef < ' a > > for UIntRef < ' a > {
83
+ impl < ' a > TryFrom < AnyRef < ' a > > for UintRef < ' a > {
84
84
type Error = Error ;
85
85
86
- fn try_from ( any : AnyRef < ' a > ) -> Result < UIntRef < ' a > > {
86
+ fn try_from ( any : AnyRef < ' a > ) -> Result < UintRef < ' a > > {
87
87
any. decode_into ( )
88
88
}
89
89
}
90
90
91
- impl < ' a > FixedTag for UIntRef < ' a > {
91
+ impl < ' a > FixedTag for UintRef < ' a > {
92
92
const TAG : Tag = Tag :: Integer ;
93
93
}
94
94
95
- impl < ' a > OrdIsValueOrd for UIntRef < ' a > { }
95
+ impl < ' a > OrdIsValueOrd for UintRef < ' a > { }
96
96
97
97
#[ cfg( test) ]
98
98
mod tests {
99
- use super :: UIntRef ;
99
+ use super :: UintRef ;
100
100
use crate :: {
101
101
asn1:: { integer:: tests:: * , AnyRef } ,
102
102
Decode , Encode , ErrorKind , SliceWriter , Tag ,
103
103
} ;
104
104
105
105
#[ test]
106
106
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( ) ) ;
111
111
112
112
assert_eq ! (
113
113
& [ 0x01 , 0x00 ] ,
114
- UIntRef :: from_der( I256_BYTES ) . unwrap( ) . as_bytes( )
114
+ UintRef :: from_der( I256_BYTES ) . unwrap( ) . as_bytes( )
115
115
) ;
116
116
117
117
assert_eq ! (
118
118
& [ 0x7F , 0xFF ] ,
119
- UIntRef :: from_der( I32767_BYTES ) . unwrap( ) . as_bytes( )
119
+ UintRef :: from_der( I32767_BYTES ) . unwrap( ) . as_bytes( )
120
120
) ;
121
121
}
122
122
@@ -130,7 +130,7 @@ mod tests {
130
130
I256_BYTES ,
131
131
I32767_BYTES ,
132
132
] {
133
- let uint = UIntRef :: from_der ( example) . unwrap ( ) ;
133
+ let uint = UintRef :: from_der ( example) . unwrap ( ) ;
134
134
135
135
let mut buf = [ 0u8 ; 128 ] ;
136
136
let mut encoder = SliceWriter :: new ( & mut buf) ;
@@ -143,7 +143,7 @@ mod tests {
143
143
144
144
#[ test]
145
145
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 ( ) )
147
147
. err ( )
148
148
. unwrap ( ) ;
149
149
0 commit comments