1use cfg_if::*;
2use std::path::Path;
3
4cfg_if! {
5 if #[cfg(feature="rt-tokio")] {
6 mod ipc_tokio;
7 pub use ipc_tokio::*;
8 } else if #[cfg(feature="rt-async-std")] {
9 mod ipc_async_std;
10 #[cfg_attr(windows, allow(unused_imports))]
11 pub use ipc_async_std::*;
12 }
13}
14
15#[allow(unused_variables)]
16pub fn is_ipc_socket_path<P: AsRef<Path>>(path: P) -> bool {
17 cfg_if! {
18 if #[cfg(windows)] {
19 let p = path.as_ref().to_path_buf().to_string_lossy().to_string().to_lowercase();
20 p.starts_with(r"\\.\pipe") && path.as_ref().exists()
21 } else if #[cfg(unix)] {
22 use std::os::unix::fs::FileTypeExt;
23 let meta = match std::fs::metadata(path) {
24 Ok(v) => v,
25 Err(_) => {
26 return false;
27 }
28 };
29 meta.file_type().is_socket()
30 } else {
31 false
32 }
33 }
34}