From 66c3e4261c8c8d6ef7c576418cfde50b92bcb832 Mon Sep 17 00:00:00 2001 From: Bill Fraser Date: Fri, 25 Sep 2026 10:43:27 -0700 Subject: [PATCH 1/2] feat: allow getting Host's inner Authority value If I have a `Host`, and need an `Authority`, right now I have to do `Authority::from_str(&host.to_string())` which involves an extra unnecessary string allocation and parse. --- src/common/host.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/host.rs b/src/common/host.rs index cb135323..75d2d772 100644 --- a/src/common/host.rs +++ b/src/common/host.rs @@ -20,6 +20,11 @@ impl Host { pub fn port(&self) -> Option { self.0.port_u16() } + + /// Get the Host value, represented as an [`Authority`]. + pub fn authority(&self) -> Authority { + self.0.clone() + } } impl Header for Host { From c0264afa059d7d6b27e8deee461f065745214026 Mon Sep 17 00:00:00 2001 From: Bill Fraser Date: Wed, 30 Sep 2026 16:26:45 -0700 Subject: [PATCH 2/2] add a From impl for Authority --- src/common/host.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/host.rs b/src/common/host.rs index 75d2d772..f62f68b1 100644 --- a/src/common/host.rs +++ b/src/common/host.rs @@ -20,11 +20,6 @@ impl Host { pub fn port(&self) -> Option { self.0.port_u16() } - - /// Get the Host value, represented as an [`Authority`]. - pub fn authority(&self) -> Authority { - self.0.clone() - } } impl Header for Host { @@ -55,6 +50,12 @@ impl From for Host { } } +impl From for Authority { + fn from(Host(authority): Host) -> Authority { + authority + } +} + impl fmt::Display for Host { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f)