distant_net/server/ref/
unix.rs1use std::future::Future;
2use std::ops::{Deref, DerefMut};
3use std::path::{Path, PathBuf};
4use std::pin::Pin;
5use std::task::{Context, Poll};
6
7use tokio::task::JoinError;
8
9use super::ServerRef;
10
11pub struct UnixSocketServerRef {
13 pub(crate) path: PathBuf,
14 pub(crate) inner: ServerRef,
15}
16
17impl UnixSocketServerRef {
18 pub fn new(path: PathBuf, inner: ServerRef) -> Self {
19 Self { path, inner }
20 }
21
22 pub fn path(&self) -> &Path {
24 &self.path
25 }
26
27 pub fn into_inner(self) -> ServerRef {
29 self.inner
30 }
31}
32
33impl Future for UnixSocketServerRef {
34 type Output = Result<(), JoinError>;
35
36 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
37 Pin::new(&mut self.inner.task).poll(cx)
38 }
39}
40
41impl Deref for UnixSocketServerRef {
42 type Target = ServerRef;
43
44 fn deref(&self) -> &Self::Target {
45 &self.inner
46 }
47}
48
49impl DerefMut for UnixSocketServerRef {
50 fn deref_mut(&mut self) -> &mut Self::Target {
51 &mut self.inner
52 }
53}