@@ -278,8 +278,8 @@ fn get_authority(rawurl: &str) ->
278278 }
279279
280280 let len = rawurl. len ( ) ;
281- let mut st = Start ;
282- let mut input = Digit ; // most restricted, start here.
281+ let mut st = State :: Start ;
282+ let mut input = Input :: Digit ; // most restricted, start here.
283283
284284 let mut userinfo = None ;
285285 let mut host = "" ;
@@ -298,15 +298,15 @@ fn get_authority(rawurl: &str) ->
298298 '0' ... '9' => ( ) ,
299299 'A' ... 'F'
300300 | 'a' ... 'f' => {
301- if input == Digit {
302- input = Hex ;
301+ if input == Input :: Digit {
302+ input = Input :: Hex ;
303303 }
304304 }
305305 'G' ... 'Z'
306306 | 'g' ... 'z'
307307 | '-' | '.' | '_' | '~' | '%'
308308 | '&' |'\'' | '(' | ')' | '+'
309- | '!' | '*' | ',' | ';' | '=' => input = Unreserved ,
309+ | '!' | '*' | ',' | ';' | '=' => input = Input :: Unreserved ,
310310 ':' | '@' | '?' | '#' | '/' => {
311311 // separators, don't change anything
312312 }
@@ -318,61 +318,61 @@ fn get_authority(rawurl: &str) ->
318318 ':' => {
319319 colon_count += 1 ;
320320 match st {
321- Start => {
321+ State :: Start => {
322322 pos = i;
323- st = PassHostPort ;
323+ st = State :: PassHostPort ;
324324 }
325- PassHostPort => {
325+ State :: PassHostPort => {
326326 // multiple colons means ipv6 address.
327- if input == Unreserved {
327+ if input == Input :: Unreserved {
328328 return Err (
329329 "Illegal characters in IPv6 address." . to_string ( ) ) ;
330330 }
331- st = Ip6Host ;
331+ st = State :: Ip6Host ;
332332 }
333- InHost => {
333+ State :: InHost => {
334334 pos = i;
335- if input == Unreserved {
335+ if input == Input :: Unreserved {
336336 // must be port
337337 host = rawurl. slice ( begin, i) ;
338- st = InPort ;
338+ st = State :: InPort ;
339339 } else {
340340 // can't be sure whether this is an ipv6 address or a port
341- st = Ip6Port ;
341+ st = State :: Ip6Port ;
342342 }
343343 }
344- Ip6Port => {
345- if input == Unreserved {
344+ State :: Ip6Port => {
345+ if input == Input :: Unreserved {
346346 return Err ( "Illegal characters in authority." . to_string ( ) ) ;
347347 }
348- st = Ip6Host ;
348+ st = State :: Ip6Host ;
349349 }
350- Ip6Host => {
350+ State :: Ip6Host => {
351351 if colon_count > 7 {
352352 host = rawurl. slice ( begin, i) ;
353353 pos = i;
354- st = InPort ;
354+ st = State :: InPort ;
355355 }
356356 }
357357 _ => return Err ( "Invalid ':' in authority." . to_string ( ) ) ,
358358 }
359- input = Digit ; // reset input class
359+ input = Input :: Digit ; // reset input class
360360 }
361361
362362 '@' => {
363- input = Digit ; // reset input class
363+ input = Input :: Digit ; // reset input class
364364 colon_count = 0 ; // reset count
365365 match st {
366- Start => {
366+ State :: Start => {
367367 let user = rawurl. slice ( begin, i) . to_string ( ) ;
368368 userinfo = Some ( UserInfo :: new ( user, None ) ) ;
369- st = InHost ;
369+ st = State :: InHost ;
370370 }
371- PassHostPort => {
371+ State :: PassHostPort => {
372372 let user = rawurl. slice ( begin, pos) . to_string ( ) ;
373373 let pass = rawurl. slice ( pos+1 , i) . to_string ( ) ;
374374 userinfo = Some ( UserInfo :: new ( user, Some ( pass) ) ) ;
375- st = InHost ;
375+ st = State :: InHost ;
376376 }
377377 _ => return Err ( "Invalid '@' in authority." . to_string ( ) ) ,
378378 }
@@ -389,19 +389,19 @@ fn get_authority(rawurl: &str) ->
389389
390390 // finish up
391391 match st {
392- Start => host = rawurl. slice ( begin, end) ,
393- PassHostPort
394- | Ip6Port => {
395- if input != Digit {
392+ State :: Start => host = rawurl. slice ( begin, end) ,
393+ State :: PassHostPort
394+ | State :: Ip6Port => {
395+ if input != Input :: Digit {
396396 return Err ( "Non-digit characters in port." . to_string ( ) ) ;
397397 }
398398 host = rawurl. slice ( begin, pos) ;
399399 port = Some ( rawurl. slice ( pos+1 , end) ) ;
400400 }
401- Ip6Host
402- | InHost => host = rawurl. slice ( begin, end) ,
403- InPort => {
404- if input != Digit {
401+ State :: Ip6Host
402+ | State :: InHost => host = rawurl. slice ( begin, end) ,
403+ State :: InPort => {
404+ if input != Input :: Digit {
405405 return Err ( "Non-digit characters in port." . to_string ( ) ) ;
406406 }
407407 port = Some ( rawurl. slice ( pos+1 , end) ) ;
0 commit comments