1use std::net::SocketAddr;
2
3use anyhow::Context;
4
5pub trait UrlExt: private::Sealed {
8 fn to_socket(&self) -> anyhow::Result<SocketAddr>;
9}
10
11impl UrlExt for url::Url {
12 fn to_socket(&self) -> anyhow::Result<SocketAddr> {
13 self.socket_addrs(|| None)?
14 .into_iter()
15 .next()
16 .with_context(|| format!("failed to convert url {self} to socket address"))
17 }
18}
19
20mod private {
21 pub trait Sealed {}
22 impl Sealed for url::Url {}
23}
24
25pub mod connect_info;
26mod layers;
27pub use layers::*;