1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate::{ServerRef, ServerState};
use std::path::{Path, PathBuf};

/// Reference to a unix socket server instance
pub struct UnixSocketServerRef {
    pub(crate) path: PathBuf,
    pub(crate) inner: Box<dyn ServerRef>,
}

impl UnixSocketServerRef {
    pub fn new(path: PathBuf, inner: Box<dyn ServerRef>) -> Self {
        Self { path, inner }
    }

    /// Returns the path to the socket
    pub fn path(&self) -> &Path {
        &self.path
    }

    /// Consumes ref, returning inner ref
    pub fn into_inner(self) -> Box<dyn ServerRef> {
        self.inner
    }
}

impl ServerRef for UnixSocketServerRef {
    fn state(&self) -> &ServerState {
        self.inner.state()
    }

    fn is_finished(&self) -> bool {
        self.inner.is_finished()
    }

    fn abort(&self) {
        self.inner.abort();
    }
}