Skip to content

Commit 0b21874

Browse files
committed
Remove/rename deprecated APIs
1 parent 8f490d4 commit 0b21874

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_str(), 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
@@ -205,12 +205,6 @@ impl Authority {
205205
host(self.as_str())
206206
}
207207

208-
#[deprecated(since="0.1.14", note="use `port_part` or `port_u16` instead")]
209-
#[doc(hidden)]
210-
pub fn port(&self) -> Option<u16> {
211-
self.port_u16()
212-
}
213-
214208
/// Get the port part of this `Authority`.
215209
///
216210
/// The port subcomponent of authority is designated by an optional port
@@ -233,7 +227,7 @@ impl Authority {
233227
/// # use http::uri::Authority;
234228
/// let authority: Authority = "example.org:80".parse().unwrap();
235229
///
236-
/// let port = authority.port_part().unwrap();
230+
/// let port = authority.port().unwrap();
237231
/// assert_eq!(port.as_u16(), 80);
238232
/// assert_eq!(port.as_str(), "80");
239233
/// ```
@@ -244,9 +238,9 @@ impl Authority {
244238
/// # use http::uri::Authority;
245239
/// let authority: Authority = "example.org".parse().unwrap();
246240
///
247-
/// assert!(authority.port_part().is_none());
241+
/// assert!(authority.port().is_none());
248242
/// ```
249-
pub fn port_part(&self) -> Option<Port<&str>> {
243+
pub fn port(&self) -> Option<Port<&str>> {
250244
let bytes = self.as_str();
251245
bytes
252246
.rfind(":")
@@ -264,7 +258,7 @@ impl Authority {
264258
/// assert_eq!(authority.port_u16(), Some(80));
265259
/// ```
266260
pub fn port_u16(&self) -> Option<u16> {
267-
self.port_part().and_then(|p| Some(p.as_u16()))
261+
self.port().and_then(|p| Some(p.as_u16()))
268262
}
269263

270264
/// 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
@@ -69,10 +69,10 @@ impl PathAndQuery {
6969
// percent-encoded in the path. If it should have been
7070
// percent-encoded, then error.
7171
0x21 |
72-
0x24...0x3B |
72+
0x24..=0x3B |
7373
0x3D |
74-
0x40...0x5F |
75-
0x61...0x7A |
74+
0x40..=0x5F |
75+
0x61..=0x7A |
7676
0x7C |
7777
0x7E => {},
7878

@@ -94,9 +94,9 @@ impl PathAndQuery {
9494
//
9595
// Allowed: 0x21 / 0x24 - 0x3B / 0x3D / 0x3F - 0x7E
9696
0x21 |
97-
0x24...0x3B |
97+
0x24..=0x3B |
9898
0x3D |
99-
0x3F...0x7E => {},
99+
0x3F..=0x7E => {},
100100

101101
b'#' => {
102102
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)