Expose connect_with_bind for Async<TcpStream>

This commit is contained in:
Aode (lion) 2022-07-22 18:05:16 -05:00
parent 5d1821946c
commit 7f6ec81760
2 changed files with 14 additions and 1 deletions

2
Cargo.lock generated
View file

@ -90,7 +90,7 @@ checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
[[package]]
name = "polldance"
version = "0.1.0"
source = "git+https://git.asonix.dog/safe-async/polldance#cf88cef83966f8afcb9fff1f0fe840075fe53f2d"
source = "git+https://git.asonix.dog/safe-async/polldance#d6d08c8bce75cfea76063fe614a784a1dc058db6"
dependencies = [
"rustix",
]

View file

@ -165,6 +165,19 @@ impl Async<TcpStream> {
}
.await
}
pub async fn connect_with_bind<A: Into<SocketAddr>, B: Into<SocketAddr>>(
socket_address: A,
bind_address: Option<B>,
) -> Result<Async<TcpStream>> {
Connect {
io: Some(
polldance::net::TcpStream::connect_with_bind(socket_address, bind_address)
.map(Arc::new),
),
}
.await
}
}
impl<T: AsFd + 'static> Async<T> {