mirror of https://github.com/chipsenkbeil/distant
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
728 B
Rust
34 lines
728 B
Rust
use std::io;
|
|
use std::path::PathBuf;
|
|
|
|
use async_trait::async_trait;
|
|
|
|
use super::Connector;
|
|
use crate::common::UnixSocketTransport;
|
|
|
|
/// Implementation of [`Connector`] to support connecting via a Unix socket.
|
|
pub struct UnixSocketConnector {
|
|
path: PathBuf,
|
|
}
|
|
|
|
impl UnixSocketConnector {
|
|
pub fn new(path: impl Into<PathBuf>) -> Self {
|
|
Self { path: path.into() }
|
|
}
|
|
}
|
|
|
|
impl<T: Into<PathBuf>> From<T> for UnixSocketConnector {
|
|
fn from(path: T) -> Self {
|
|
Self::new(path)
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
impl Connector for UnixSocketConnector {
|
|
type Transport = UnixSocketTransport;
|
|
|
|
async fn connect(self) -> io::Result<Self::Transport> {
|
|
UnixSocketTransport::connect(self.path).await
|
|
}
|
|
}
|