1717//! assert_eq!(uri.host(), None);
1818//!
1919//! 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"));
2121//! assert_eq!(uri.host(), Some("www.rust-lang.org"));
2222//! assert_eq!(uri.path(), "/install.html");
2323//! ```
@@ -28,9 +28,6 @@ use byte_str::ByteStr;
2828use bytes:: Bytes ;
2929
3030use 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 ;
3431use std:: hash:: { Hash , Hasher } ;
3532use std:: str:: { self , FromStr } ;
3633use std:: error:: Error ;
@@ -91,7 +88,7 @@ mod tests;
9188/// assert_eq!(uri.host(), None);
9289///
9390/// 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"));
9592/// assert_eq!(uri.host(), Some("www.rust-lang.org"));
9693/// assert_eq!(uri.path(), "/install.html");
9794/// ```
@@ -441,7 +438,7 @@ impl Uri {
441438 ///
442439 /// let uri: Uri = "http://example.org/hello/world".parse().unwrap();
443440 ///
444- /// assert_eq!(uri.scheme_part (), Some(&Scheme::HTTP));
441+ /// assert_eq!(uri.scheme (), Some(&Scheme::HTTP));
445442 /// ```
446443 ///
447444 ///
@@ -451,24 +448,17 @@ impl Uri {
451448 /// # use http::Uri;
452449 /// let uri: Uri = "/hello/world".parse().unwrap();
453450 ///
454- /// assert!(uri.scheme_part ().is_none());
451+ /// assert!(uri.scheme ().is_none());
455452 /// ```
456453 #[ inline]
457- pub fn scheme_part ( & self ) -> Option < & Scheme > {
454+ pub fn scheme ( & self ) -> Option < & Scheme > {
458455 if self . scheme . inner . is_none ( ) {
459456 None
460457 } else {
461458 Some ( & self . scheme )
462459 }
463460 }
464461
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-
472462 /// Get the scheme of this `Uri` as a `&str`.
473463 ///
474464 /// # Example
@@ -515,7 +505,7 @@ impl Uri {
515505 /// # use http::Uri;
516506 /// let uri: Uri = "http://example.org:80/hello/world".parse().unwrap();
517507 ///
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"));
519509 /// ```
520510 ///
521511 ///
@@ -525,28 +515,17 @@ impl Uri {
525515 /// # use http::Uri;
526516 /// let uri: Uri = "/hello/world".parse().unwrap();
527517 ///
528- /// assert!(uri.authority_part ().is_none());
518+ /// assert!(uri.authority ().is_none());
529519 /// ```
530520 #[ inline]
531- pub fn authority_part ( & self ) -> Option < & Authority > {
521+ pub fn authority ( & self ) -> Option < & Authority > {
532522 if self . authority . data . is_empty ( ) {
533523 None
534524 } else {
535525 Some ( & self . authority )
536526 }
537527 }
538528
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-
550529 /// Get the host of this `Uri`.
551530 ///
552531 /// The host subcomponent of authority is identified by an IP literal
@@ -582,13 +561,7 @@ impl Uri {
582561 /// ```
583562 #[ inline]
584563 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 ( ) )
592565 }
593566
594567 /// Get the port part of this `Uri`.
@@ -613,7 +586,7 @@ impl Uri {
613586 /// # use http::Uri;
614587 /// let uri: Uri = "http://example.org:80/hello/world".parse().unwrap();
615588 ///
616- /// let port = uri.port_part ().unwrap();
589+ /// let port = uri.port ().unwrap();
617590 /// assert_eq!(port.as_u16(), 80);
618591 /// ```
619592 ///
@@ -623,7 +596,7 @@ impl Uri {
623596 /// # use http::Uri;
624597 /// let uri: Uri = "http://example.org/hello/world".parse().unwrap();
625598 ///
626- /// assert!(uri.port_part ().is_none());
599+ /// assert!(uri.port ().is_none());
627600 /// ```
628601 ///
629602 /// Relative URI
@@ -632,11 +605,11 @@ impl Uri {
632605 /// # use http::Uri;
633606 /// let uri: Uri = "/hello/world".parse().unwrap();
634607 ///
635- /// assert!(uri.port_part ().is_none());
608+ /// assert!(uri.port ().is_none());
636609 /// ```
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 ( ) )
640613 }
641614
642615 /// Get the port of this `Uri` as a `u16`.
@@ -651,7 +624,7 @@ impl Uri {
651624 /// assert_eq!(uri.port_u16(), Some(80));
652625 /// ```
653626 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 ( ) ) )
655628 }
656629
657630 /// Get the query string of this `Uri`, starting after the `?`.
@@ -776,7 +749,7 @@ impl<'a> HttpTryFrom<&'a Uri> for Uri {
776749///
777750/// assert_eq!(uri.path(), "/foo");
778751///
779- /// assert!(uri.scheme_part ().is_none());
752+ /// assert!(uri.scheme ().is_none());
780753/// assert!(uri.authority().is_none());
781754/// ```
782755///
@@ -791,7 +764,7 @@ impl<'a> HttpTryFrom<&'a Uri> for Uri {
791764///
792765/// let uri = Uri::from_parts(parts).unwrap();
793766///
794- /// assert_eq!(uri.scheme_part ().unwrap().as_str(), "http");
767+ /// assert_eq!(uri.scheme ().unwrap().as_str(), "http");
795768/// assert_eq!(uri.authority().unwrap(), "foo.com");
796769/// assert_eq!(uri.path(), "/foo");
797770/// ```
@@ -894,11 +867,11 @@ impl FromStr for Uri {
894867
895868impl PartialEq for Uri {
896869 fn eq ( & self , other : & Uri ) -> bool {
897- if self . scheme_part ( ) != other. scheme_part ( ) {
870+ if self . scheme ( ) != other. scheme ( ) {
898871 return false ;
899872 }
900873
901- if self . authority_part ( ) != other. authority_part ( ) {
874+ if self . authority ( ) != other. authority ( ) {
902875 return false ;
903876 }
904877
@@ -919,7 +892,7 @@ impl PartialEq<str> for Uri {
919892 let mut other = other. as_bytes ( ) ;
920893 let mut absolute = false ;
921894
922- if let Some ( scheme) = self . scheme_part ( ) {
895+ if let Some ( scheme) = self . scheme ( ) {
923896 let scheme = scheme. as_str ( ) . as_bytes ( ) ;
924897 absolute = true ;
925898
@@ -940,7 +913,7 @@ impl PartialEq<str> for Uri {
940913 other = & other[ 3 ..] ;
941914 }
942915
943- if let Some ( auth) = self . authority_part ( ) {
916+ if let Some ( auth) = self . authority ( ) {
944917 let len = auth. data . len ( ) ;
945918 absolute = true ;
946919
@@ -1027,11 +1000,11 @@ impl Default for Uri {
10271000
10281001impl fmt:: Display for Uri {
10291002 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1030- if let Some ( scheme) = self . scheme_part ( ) {
1003+ if let Some ( scheme) = self . scheme ( ) {
10311004 write ! ( f, "{}://" , scheme) ?;
10321005 }
10331006
1034- if let Some ( authority) = self . authority_part ( ) {
1007+ if let Some ( authority) = self . authority ( ) {
10351008 write ! ( f, "{}" , authority) ?;
10361009 }
10371010
@@ -1124,7 +1097,7 @@ impl Hash for Uri {
11241097 state. write_u8 ( 0xff ) ;
11251098 }
11261099
1127- if let Some ( auth) = self . authority_part ( ) {
1100+ if let Some ( auth) = self . authority ( ) {
11281101 auth. hash ( state) ;
11291102 }
11301103
0 commit comments