1#[cfg(unix)]
4use tor_general_addr::unix;
5
6#[cfg(unix)]
8pub(crate) fn new_unnamed_socketaddr() -> std::io::Result<unix::SocketAddr> {
9 unix::SocketAddr::from_pathname("")
12}
13
14#[derive(Clone, Debug, thiserror::Error)]
18#[error("Operation not supported on this kind of AF_UNIX address")]
19#[non_exhaustive]
20pub struct UnsupportedAfUnixAddressType;
21
22#[deprecated]
24pub type UnsupportedUnixAddressType = UnsupportedAfUnixAddressType;
25
26impl From<UnsupportedAfUnixAddressType> for std::io::Error {
27 fn from(value: UnsupportedAfUnixAddressType) -> Self {
28 std::io::Error::new(std::io::ErrorKind::Unsupported, value)
29 }
30}
31
32#[cfg(test)]
33mod test {
34 #[cfg(unix)]
35 use super::*;
36
37 #[test]
38 #[cfg(unix)]
39 fn unnamed() {
40 let u = new_unnamed_socketaddr().expect("couldn't construct unnamed AF_UNIX socketaddr");
41 assert!(u.is_unnamed());
42 assert!(u.as_pathname().is_none());
43
44 let n = unix::SocketAddr::from_pathname("/home/arachnidsGrip/.arti/SOCKET")
45 .expect("Couldn't construct named socketaddr");
46 assert!(!n.is_unnamed());
47 }
48}