17
17
//! assert_eq!(uri.host(), None);
18
18
//!
19
19
//! let uri = "https://www.rust-lang.org/install.html".parse::<Uri>().unwrap();
20
- //! assert_eq!(uri.scheme_part().map(|s| s.as_str() ), Some("https"));
20
+ //! assert_eq!(uri.scheme_str( ), Some("https"));
21
21
//! assert_eq!(uri.host(), Some("www.rust-lang.org"));
22
22
//! assert_eq!(uri.path(), "/install.html");
23
23
//! ```
@@ -28,9 +28,6 @@ use byte_str::ByteStr;
28
28
use bytes:: Bytes ;
29
29
30
30
use std:: { fmt, u8, u16} ;
31
- // Deprecated in 1.26, needed until our minimum version is >=1.23.
32
- #[ allow( unused, deprecated) ]
33
- use std:: ascii:: AsciiExt ;
34
31
use std:: hash:: { Hash , Hasher } ;
35
32
use std:: str:: { self , FromStr } ;
36
33
use std:: error:: Error ;
@@ -91,7 +88,7 @@ mod tests;
91
88
/// assert_eq!(uri.host(), None);
92
89
///
93
90
/// let uri = "https://www.rust-lang.org/install.html".parse::<Uri>().unwrap();
94
- /// assert_eq!(uri.scheme_part().map(|s| s.as_str() ), Some("https"));
91
+ /// assert_eq!(uri.scheme_str( ), Some("https"));
95
92
/// assert_eq!(uri.host(), Some("www.rust-lang.org"));
96
93
/// assert_eq!(uri.path(), "/install.html");
97
94
/// ```
@@ -441,7 +438,7 @@ impl Uri {
441
438
///
442
439
/// let uri: Uri = "http://example.org/hello/world".parse().unwrap();
443
440
///
444
- /// assert_eq!(uri.scheme_part (), Some(&Scheme::HTTP));
441
+ /// assert_eq!(uri.scheme (), Some(&Scheme::HTTP));
445
442
/// ```
446
443
///
447
444
///
@@ -451,24 +448,17 @@ impl Uri {
451
448
/// # use http::Uri;
452
449
/// let uri: Uri = "/hello/world".parse().unwrap();
453
450
///
454
- /// assert!(uri.scheme_part ().is_none());
451
+ /// assert!(uri.scheme ().is_none());
455
452
/// ```
456
453
#[ inline]
457
- pub fn scheme_part ( & self ) -> Option < & Scheme > {
454
+ pub fn scheme ( & self ) -> Option < & Scheme > {
458
455
if self . scheme . inner . is_none ( ) {
459
456
None
460
457
} else {
461
458
Some ( & self . scheme )
462
459
}
463
460
}
464
461
465
- #[ deprecated( since = "0.1.2" , note = "use scheme_part or scheme_str instead" ) ]
466
- #[ doc( hidden) ]
467
- #[ inline]
468
- pub fn scheme ( & self ) -> Option < & str > {
469
- self . scheme_str ( )
470
- }
471
-
472
462
/// Get the scheme of this `Uri` as a `&str`.
473
463
///
474
464
/// # Example
@@ -515,7 +505,7 @@ impl Uri {
515
505
/// # use http::Uri;
516
506
/// let uri: Uri = "http://example.org:80/hello/world".parse().unwrap();
517
507
///
518
- /// assert_eq!(uri.authority_part ().map(|a| a.as_str()), Some("example.org:80"));
508
+ /// assert_eq!(uri.authority ().map(|a| a.as_str()), Some("example.org:80"));
519
509
/// ```
520
510
///
521
511
///
@@ -525,28 +515,17 @@ impl Uri {
525
515
/// # use http::Uri;
526
516
/// let uri: Uri = "/hello/world".parse().unwrap();
527
517
///
528
- /// assert!(uri.authority_part ().is_none());
518
+ /// assert!(uri.authority ().is_none());
529
519
/// ```
530
520
#[ inline]
531
- pub fn authority_part ( & self ) -> Option < & Authority > {
521
+ pub fn authority ( & self ) -> Option < & Authority > {
532
522
if self . authority . data . is_empty ( ) {
533
523
None
534
524
} else {
535
525
Some ( & self . authority )
536
526
}
537
527
}
538
528
539
- #[ deprecated( since = "0.1.1" , note = "use authority_part instead" ) ]
540
- #[ doc( hidden) ]
541
- #[ inline]
542
- pub fn authority ( & self ) -> Option < & str > {
543
- if self . authority . data . is_empty ( ) {
544
- None
545
- } else {
546
- Some ( self . authority . as_str ( ) )
547
- }
548
- }
549
-
550
529
/// Get the host of this `Uri`.
551
530
///
552
531
/// The host subcomponent of authority is identified by an IP literal
@@ -582,13 +561,7 @@ impl Uri {
582
561
/// ```
583
562
#[ inline]
584
563
pub fn host ( & self ) -> Option < & str > {
585
- self . authority_part ( ) . map ( |a| a. host ( ) )
586
- }
587
-
588
- #[ deprecated( since="0.1.14" , note="use `port_part` or `port_u16` instead" ) ]
589
- #[ doc( hidden) ]
590
- pub fn port ( & self ) -> Option < u16 > {
591
- self . port_u16 ( )
564
+ self . authority ( ) . map ( |a| a. host ( ) )
592
565
}
593
566
594
567
/// Get the port part of this `Uri`.
@@ -613,7 +586,7 @@ impl Uri {
613
586
/// # use http::Uri;
614
587
/// let uri: Uri = "http://example.org:80/hello/world".parse().unwrap();
615
588
///
616
- /// let port = uri.port_part ().unwrap();
589
+ /// let port = uri.port ().unwrap();
617
590
/// assert_eq!(port.as_u16(), 80);
618
591
/// ```
619
592
///
@@ -623,7 +596,7 @@ impl Uri {
623
596
/// # use http::Uri;
624
597
/// let uri: Uri = "http://example.org/hello/world".parse().unwrap();
625
598
///
626
- /// assert!(uri.port_part ().is_none());
599
+ /// assert!(uri.port ().is_none());
627
600
/// ```
628
601
///
629
602
/// Relative URI
@@ -632,11 +605,11 @@ impl Uri {
632
605
/// # use http::Uri;
633
606
/// let uri: Uri = "/hello/world".parse().unwrap();
634
607
///
635
- /// assert!(uri.port_part ().is_none());
608
+ /// assert!(uri.port ().is_none());
636
609
/// ```
637
- pub fn port_part ( & self ) -> Option < Port < & str > > {
638
- self . authority_part ( )
639
- . and_then ( |a| a. port_part ( ) )
610
+ pub fn port ( & self ) -> Option < Port < & str > > {
611
+ self . authority ( )
612
+ . and_then ( |a| a. port ( ) )
640
613
}
641
614
642
615
/// Get the port of this `Uri` as a `u16`.
@@ -651,7 +624,7 @@ impl Uri {
651
624
/// assert_eq!(uri.port_u16(), Some(80));
652
625
/// ```
653
626
pub fn port_u16 ( & self ) -> Option < u16 > {
654
- self . port_part ( ) . and_then ( |p| Some ( p. as_u16 ( ) ) )
627
+ self . port ( ) . and_then ( |p| Some ( p. as_u16 ( ) ) )
655
628
}
656
629
657
630
/// Get the query string of this `Uri`, starting after the `?`.
@@ -776,7 +749,7 @@ impl<'a> HttpTryFrom<&'a Uri> for Uri {
776
749
///
777
750
/// assert_eq!(uri.path(), "/foo");
778
751
///
779
- /// assert!(uri.scheme_part ().is_none());
752
+ /// assert!(uri.scheme ().is_none());
780
753
/// assert!(uri.authority().is_none());
781
754
/// ```
782
755
///
@@ -791,7 +764,7 @@ impl<'a> HttpTryFrom<&'a Uri> for Uri {
791
764
///
792
765
/// let uri = Uri::from_parts(parts).unwrap();
793
766
///
794
- /// assert_eq!(uri.scheme_part ().unwrap().as_str(), "http");
767
+ /// assert_eq!(uri.scheme ().unwrap().as_str(), "http");
795
768
/// assert_eq!(uri.authority().unwrap(), "foo.com");
796
769
/// assert_eq!(uri.path(), "/foo");
797
770
/// ```
@@ -894,11 +867,11 @@ impl FromStr for Uri {
894
867
895
868
impl PartialEq for Uri {
896
869
fn eq ( & self , other : & Uri ) -> bool {
897
- if self . scheme_part ( ) != other. scheme_part ( ) {
870
+ if self . scheme ( ) != other. scheme ( ) {
898
871
return false ;
899
872
}
900
873
901
- if self . authority_part ( ) != other. authority_part ( ) {
874
+ if self . authority ( ) != other. authority ( ) {
902
875
return false ;
903
876
}
904
877
@@ -919,7 +892,7 @@ impl PartialEq<str> for Uri {
919
892
let mut other = other. as_bytes ( ) ;
920
893
let mut absolute = false ;
921
894
922
- if let Some ( scheme) = self . scheme_part ( ) {
895
+ if let Some ( scheme) = self . scheme ( ) {
923
896
let scheme = scheme. as_str ( ) . as_bytes ( ) ;
924
897
absolute = true ;
925
898
@@ -940,7 +913,7 @@ impl PartialEq<str> for Uri {
940
913
other = & other[ 3 ..] ;
941
914
}
942
915
943
- if let Some ( auth) = self . authority_part ( ) {
916
+ if let Some ( auth) = self . authority ( ) {
944
917
let len = auth. data . len ( ) ;
945
918
absolute = true ;
946
919
@@ -1027,11 +1000,11 @@ impl Default for Uri {
1027
1000
1028
1001
impl fmt:: Display for Uri {
1029
1002
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1030
- if let Some ( scheme) = self . scheme_part ( ) {
1003
+ if let Some ( scheme) = self . scheme ( ) {
1031
1004
write ! ( f, "{}://" , scheme) ?;
1032
1005
}
1033
1006
1034
- if let Some ( authority) = self . authority_part ( ) {
1007
+ if let Some ( authority) = self . authority ( ) {
1035
1008
write ! ( f, "{}" , authority) ?;
1036
1009
}
1037
1010
@@ -1124,7 +1097,7 @@ impl Hash for Uri {
1124
1097
state. write_u8 ( 0xff ) ;
1125
1098
}
1126
1099
1127
- if let Some ( auth) = self . authority_part ( ) {
1100
+ if let Some ( auth) = self . authority ( ) {
1128
1101
auth. hash ( state) ;
1129
1102
}
1130
1103
0 commit comments