use std::{
path::{Path, PathBuf},
sync::Arc,
};
pub trait IntoUnixSocket: sealed::Sealed {
fn unix_socket(self) -> Arc<Path>;
}
impl IntoUnixSocket for String {
fn unix_socket(self) -> Arc<Path> {
Arc::from(PathBuf::from(self))
}
}
impl IntoUnixSocket for &'_ str {
fn unix_socket(self) -> Arc<Path> {
Arc::from(PathBuf::from(self))
}
}
impl IntoUnixSocket for &'_ Path {
fn unix_socket(self) -> Arc<Path> {
Arc::from(self)
}
}
impl IntoUnixSocket for PathBuf {
fn unix_socket(self) -> Arc<Path> {
Arc::from(self)
}
}
impl IntoUnixSocket for Arc<Path> {
fn unix_socket(self) -> Arc<Path> {
self
}
}
mod sealed {
use std::{
path::{Path, PathBuf},
sync::Arc,
};
pub trait Sealed {}
impl Sealed for String {}
impl Sealed for &'_ str {}
impl Sealed for &'_ Path {}
impl Sealed for PathBuf {}
impl Sealed for Arc<Path> {}
}