1use crate::{
2 futures::{BindFuture, ConnectFuture, FetchLocalAddrFuture, SetRemoteAddr, StartFuture},
3 P2pSocket,
4};
5
6pub trait P2pSocketExt: P2pSocket {
7 fn bind(bootstrap: Self::Addr) -> BindFuture<Self> {
8 BindFuture {
9 arg: Some(bootstrap),
10 }
11 }
12
13 fn connect(&self, label: Self::Addr, port: u16) -> ConnectFuture<'_, Self> {
14 ConnectFuture {
15 socket: self,
16 label: Some(label),
17 port,
18 }
19 }
20
21 fn start(&mut self) -> StartFuture<'_, Self> {
22 StartFuture { socket: self }
23 }
24
25 fn fetch_local_addr(&mut self) -> FetchLocalAddrFuture<'_, Self> {
26 FetchLocalAddrFuture { socket: self }
27 }
28
29 fn set_remote_addr(&self, remote: Self::Addr) -> SetRemoteAddr<'_, Self> {
30 SetRemoteAddr {
31 socket: self,
32 remote: Some(remote),
33 }
34 }
35}
36
37impl<T: P2pSocket> P2pSocketExt for T {}
38