1use super::*;
3
4use std::path::Path;
5
6use tokio::net::UnixStream;
7
8pub struct UnixConnector<P>(P);
10
11impl<P> UnixConnector<P> {
12 pub fn new(path: P) -> Self {
13 Self(path)
14 }
15
16 pub fn get_path(&self) -> &P {
17 &self.0
18 }
19
20 pub fn get_path_mut(&mut self) -> &mut P {
21 &mut self.0
22 }
23}
24
25impl<P, R> Tether<UnixConnector<P>, R>
26where
27 R: Resolver<UnixConnector<P>>,
28 P: AsRef<Path>,
29{
30 pub async fn connect_unix(path: P, resolver: R) -> Result<Self, std::io::Error> {
32 let connector = UnixConnector::new(path);
33 Tether::connect(connector, resolver).await
34 }
35}
36
37impl<P> Io for UnixConnector<P>
38where
39 P: AsRef<Path>,
40{
41 type Output = UnixStream;
42
43 fn connect(&mut self) -> PinFut<Result<Self::Output, std::io::Error>> {
44 let path = self.0.as_ref().to_path_buf();
45 Box::pin(UnixStream::connect(path))
46 }
47}