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