Skip to content

Commit 5e395ef

Browse files
committed
Remove/rename deprecated APIs
1 parent e4f013a commit 5e395ef

File tree

6 files changed

+111
-143
lines changed

6 files changed

+111
-143
lines changed

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,11 @@
148148
//!
149149
//! ```
150150
//! use http::Uri;
151+
//! use http::uri::Scheme;
151152
//!
152153
//! let uri = "https://www.rust-lang.org/index.html".parse::<Uri>().unwrap();
153154
//!
154-
//! assert_eq!(uri.scheme(), Some("https"));
155+
//! assert_eq!(uri.scheme(), Some(&Scheme::HTTPS));
155156
//! assert_eq!(uri.host(), Some("www.rust-lang.org"));
156157
//! assert_eq!(uri.path(), "/index.html");
157158
//! assert_eq!(uri.query(), None);

src/uri/authority.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,6 @@ impl Authority {
197197
host(self.as_str())
198198
}
199199

200-
#[deprecated(since="0.1.14", note="use `port_part` or `port_u16` instead")]
201-
#[doc(hidden)]
202-
pub fn port(&self) -> Option<u16> {
203-
self.port_u16()
204-
}
205-
206200
/// Get the port part of this `Authority`.
207201
///
208202
/// The port subcomponent of authority is designated by an optional port
@@ -225,7 +219,7 @@ impl Authority {
225219
/// # use http::uri::Authority;
226220
/// let authority: Authority = "example.org:80".parse().unwrap();
227221
///
228-
/// let port = authority.port_part().unwrap();
222+
/// let port = authority.port().unwrap();
229223
/// assert_eq!(port.as_u16(), 80);
230224
/// assert_eq!(port.as_str(), "80");
231225
/// ```
@@ -236,9 +230,9 @@ impl Authority {
236230
/// # use http::uri::Authority;
237231
/// let authority: Authority = "example.org".parse().unwrap();
238232
///
239-
/// assert!(authority.port_part().is_none());
233+
/// assert!(authority.port().is_none());
240234
/// ```
241-
pub fn port_part(&self) -> Option<Port<&str>> {
235+
pub fn port(&self) -> Option<Port<&str>> {
242236
let bytes = self.as_str();
243237
bytes
244238
.rfind(":")
@@ -256,7 +250,7 @@ impl Authority {
256250
/// assert_eq!(authority.port_u16(), Some(80));
257251
/// ```
258252
pub fn port_u16(&self) -> Option<u16> {
259-
self.port_part().and_then(|p| Some(p.as_u16()))
253+
self.port().and_then(|p| Some(p.as_u16()))
260254
}
261255

262256
/// Return a str representation of the authority

src/uri/mod.rs

Lines changed: 25 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
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;
2828
use bytes::Bytes;
2929

3030
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;
3431
use std::hash::{Hash, Hasher};
3532
use std::str::{self, FromStr};
3633
use 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

895868
impl 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

10281001
impl 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

src/uri/path.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ impl PathAndQuery {
6565
// percent-encoded in the path. If it should have been
6666
// percent-encoded, then error.
6767
0x21 |
68-
0x24...0x3B |
68+
0x24..=0x3B |
6969
0x3D |
70-
0x40...0x5F |
71-
0x61...0x7A |
70+
0x40..=0x5F |
71+
0x61..=0x7A |
7272
0x7C |
7373
0x7E => {},
7474

@@ -86,9 +86,9 @@ impl PathAndQuery {
8686
//
8787
// Allowed: 0x21 / 0x24 - 0x3B / 0x3D / 0x3F - 0x7E
8888
0x21 |
89-
0x24...0x3B |
89+
0x24..=0x3B |
9090
0x3D |
91-
0x3F...0x7E => {},
91+
0x3F..=0x7E => {},
9292

9393
b'#' => {
9494
fragment = Some(i);

src/uri/port.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl<T> Port<T> {
1919
/// # use http::uri::Authority;
2020
/// let authority: Authority = "example.org:80".parse().unwrap();
2121
///
22-
/// let port = authority.port_part().unwrap();
22+
/// let port = authority.port().unwrap();
2323
/// assert_eq!(port.as_u16(), 80);
2424
/// ```
2525
pub fn as_u16(&self) -> u16 {
@@ -57,7 +57,7 @@ where
5757
/// # use http::uri::Authority;
5858
/// let authority: Authority = "example.org:80".parse().unwrap();
5959
///
60-
/// let port = authority.port_part().unwrap();
60+
/// let port = authority.port().unwrap();
6161
/// assert_eq!(port.as_str(), "80");
6262
/// ```
6363
pub fn as_str(&self) -> &str {

0 commit comments

Comments
 (0)