From c9b4a4f39bfa752a3285a93e56c2ddb1d34f2de1 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 17 May 2021 11:21:17 +0200 Subject: [PATCH] uri: drop anyhow::Error and improve docs Signed-off-by: Wolfgang Bumiller --- proxmox-http/src/client/connector.rs | 2 +- proxmox-http/src/uri.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/proxmox-http/src/client/connector.rs b/proxmox-http/src/client/connector.rs index eac83354..abbd0f1a 100644 --- a/proxmox-http/src/client/connector.rs +++ b/proxmox-http/src/client/connector.rs @@ -135,7 +135,7 @@ impl hyper::service::Service for HttpsConnector { let proxy_authority = match build_authority(&proxy.host, proxy.port) { Ok(authority) => authority, - Err(err) => return futures::future::err(err).boxed(), + Err(err) => return futures::future::err(err.into()).boxed(), }; let proxy_uri = match Uri::builder() diff --git a/proxmox-http/src/uri.rs b/proxmox-http/src/uri.rs index ca671612..0f05ec7e 100644 --- a/proxmox-http/src/uri.rs +++ b/proxmox-http/src/uri.rs @@ -1,9 +1,10 @@ -use anyhow::Error; +//! URI Related helpers, such as `build_authority` -use http::uri::Authority; +use http::uri::{Authority, InvalidUri}; -// Build a http::uri::Authority ("host:port"), use '[..]' around IPv6 addresses -pub fn build_authority(host: &str, port: u16) -> Result { +// Build an [`Authority`](http::uri::Authority) from a combination of `host` and `port`, ensuring that +// IPv6 addresses are enclosed in brackets. +pub fn build_authority(host: &str, port: u16) -> Result { let bytes = host.as_bytes(); let len = bytes.len(); let authority =