@@ -4,8 +4,7 @@ use serde::forward_to_deserialize_any;
44use serde:: serde_if_integer128;
55use std:: convert:: TryInto ;
66
7- use super :: MaxMindDBError ;
8- use super :: MaxMindDBError :: DecodingError ;
7+ use super :: MaxMindDbError ;
98
109fn to_usize ( base : u8 , bytes : & [ u8 ] ) -> usize {
1110 bytes
@@ -134,7 +133,7 @@ impl<'de> Decoder<'de> {
134133 14 => Value :: Bool ( self . decode_bool ( size) ?) ,
135134 15 => Value :: F32 ( self . decode_float ( size) ?) ,
136135 u => {
137- return Err ( MaxMindDBError :: InvalidDatabaseError ( format ! (
136+ return Err ( MaxMindDbError :: InvalidDatabase ( format ! (
138137 "Unknown data type: {u:?}"
139138 ) ) )
140139 }
@@ -151,7 +150,7 @@ impl<'de> Decoder<'de> {
151150 fn decode_bool ( & mut self , size : usize ) -> DecodeResult < bool > {
152151 match size {
153152 0 | 1 => Ok ( size != 0 ) ,
154- s => Err ( MaxMindDBError :: InvalidDatabaseError ( format ! (
153+ s => Err ( MaxMindDbError :: InvalidDatabase ( format ! (
155154 "bool of size {s:?}"
156155 ) ) ) ,
157156 }
@@ -170,7 +169,7 @@ impl<'de> Decoder<'de> {
170169 let value: [ u8 ; 4 ] = self . buf [ self . current_ptr ..new_offset]
171170 . try_into ( )
172171 . map_err ( |_| {
173- MaxMindDBError :: InvalidDatabaseError ( format ! (
172+ MaxMindDbError :: InvalidDatabase ( format ! (
174173 "float of size {:?}" ,
175174 new_offset - self . current_ptr
176175 ) )
@@ -185,7 +184,7 @@ impl<'de> Decoder<'de> {
185184 let value: [ u8 ; 8 ] = self . buf [ self . current_ptr ..new_offset]
186185 . try_into ( )
187186 . map_err ( |_| {
188- MaxMindDBError :: InvalidDatabaseError ( format ! (
187+ MaxMindDbError :: InvalidDatabase ( format ! (
189188 "double of size {:?}" ,
190189 new_offset - self . current_ptr
191190 ) )
@@ -206,7 +205,7 @@ impl<'de> Decoder<'de> {
206205 self . current_ptr = new_offset;
207206 Ok ( value)
208207 }
209- s => Err ( MaxMindDBError :: InvalidDatabaseError ( format ! (
208+ s => Err ( MaxMindDbError :: InvalidDatabase ( format ! (
210209 "u64 of size {s:?}"
211210 ) ) ) ,
212211 }
@@ -227,7 +226,7 @@ impl<'de> Decoder<'de> {
227226 self . current_ptr = new_offset;
228227 Ok ( value)
229228 }
230- s => Err ( MaxMindDBError :: InvalidDatabaseError ( format!(
229+ s => Err ( MaxMindDbError :: InvalidDatabase ( format!(
231230 "u128 of size {s:?}"
232231 ) ) ) ,
233232 }
@@ -245,7 +244,7 @@ impl<'de> Decoder<'de> {
245244 self . current_ptr = new_offset;
246245 Ok ( value)
247246 }
248- s => Err ( MaxMindDBError :: InvalidDatabaseError ( format ! (
247+ s => Err ( MaxMindDbError :: InvalidDatabase ( format ! (
249248 "u32 of size {s:?}"
250249 ) ) ) ,
251250 }
@@ -262,7 +261,7 @@ impl<'de> Decoder<'de> {
262261 self . current_ptr = new_offset;
263262 Ok ( value)
264263 }
265- s => Err ( MaxMindDBError :: InvalidDatabaseError ( format ! (
264+ s => Err ( MaxMindDbError :: InvalidDatabase ( format ! (
266265 "u16 of size {s:?}"
267266 ) ) ) ,
268267 }
@@ -279,7 +278,7 @@ impl<'de> Decoder<'de> {
279278 self . current_ptr = new_offset;
280279 Ok ( value)
281280 }
282- s => Err ( MaxMindDBError :: InvalidDatabaseError ( format ! (
281+ s => Err ( MaxMindDbError :: InvalidDatabase ( format ! (
283282 "int32 of size {s:?}"
284283 ) ) ) ,
285284 }
@@ -338,17 +337,17 @@ impl<'de> Decoder<'de> {
338337 self . current_ptr = new_offset;
339338 match from_utf8 ( bytes) {
340339 Ok ( v) => Ok ( v) ,
341- Err ( _) => Err ( MaxMindDBError :: InvalidDatabaseError (
340+ Err ( _) => Err ( MaxMindDbError :: InvalidDatabase (
342341 "error decoding string" . to_owned ( ) ,
343342 ) ) ,
344343 }
345344 }
346345}
347346
348- pub type DecodeResult < T > = Result < T , MaxMindDBError > ;
347+ pub type DecodeResult < T > = Result < T , MaxMindDbError > ;
349348
350349impl < ' de : ' a , ' a > de:: Deserializer < ' de > for & ' a mut Decoder < ' de > {
351- type Error = MaxMindDBError ;
350+ type Error = MaxMindDbError ;
352351
353352 fn deserialize_any < V > ( self , visitor : V ) -> DecodeResult < V :: Value >
354353 where
@@ -383,7 +382,7 @@ struct ArrayAccess<'a, 'de: 'a> {
383382// `SeqAccess` is provided to the `Visitor` to give it the ability to iterate
384383// through elements of the sequence.
385384impl < ' de > SeqAccess < ' de > for ArrayAccess < ' _ , ' de > {
386- type Error = MaxMindDBError ;
385+ type Error = MaxMindDbError ;
387386
388387 fn next_element_seed < T > ( & mut self , seed : T ) -> DecodeResult < Option < T :: Value > >
389388 where
@@ -408,7 +407,7 @@ struct MapAccessor<'a, 'de: 'a> {
408407// `MapAccess` is provided to the `Visitor` to give it the ability to iterate
409408// through entries of the map.
410409impl < ' de > MapAccess < ' de > for MapAccessor < ' _ , ' de > {
411- type Error = MaxMindDBError ;
410+ type Error = MaxMindDbError ;
412411
413412 fn next_key_seed < K > ( & mut self , seed : K ) -> DecodeResult < Option < K :: Value > >
414413 where
@@ -430,7 +429,7 @@ impl<'de> MapAccess<'de> for MapAccessor<'_, 'de> {
430429 {
431430 // Check if there are no more entries.
432431 if self . count == 0 {
433- return Err ( DecodingError ( "no more entries" . to_owned ( ) ) ) ;
432+ return Err ( MaxMindDbError :: Decoding ( "no more entries" . to_owned ( ) ) ) ;
434433 }
435434 self . count -= 1 ;
436435
0 commit comments