use tor_general_addr::unix;
#[cfg(unix)]
pub(crate) fn new_unnamed_socketaddr() -> std::io::Result<unix::SocketAddr> {
unix::SocketAddr::from_pathname("")
}
#[derive(Clone, Debug, thiserror::Error)]
#[error("Operation not supported on this kind of AF_UNIX address")]
#[non_exhaustive]
pub struct UnsupportedAfUnixAddressType;
#[deprecated]
pub type UnsupportedUnixAddressType = UnsupportedAfUnixAddressType;
impl From<UnsupportedAfUnixAddressType> for std::io::Error {
fn from(value: UnsupportedAfUnixAddressType) -> Self {
std::io::Error::new(std::io::ErrorKind::Unsupported, value)
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
#[cfg(unix)]
fn unnamed() {
let u = new_unnamed_socketaddr().expect("couldn't construct unnamed AF_UNIX socketaddr");
assert!(u.is_unnamed());
assert!(u.as_pathname().is_none());
let n = unix::SocketAddr::from_pathname("/home/arachnidsGrip/.arti/SOCKET")
.expect("Couldn't construct named socketaddr");
assert!(!n.is_unnamed());
}
}