aboutsummaryrefslogtreecommitdiff
path: root/src/sys/unix/uds/socketaddr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/unix/uds/socketaddr.rs')
-rw-r--r--src/sys/unix/uds/socketaddr.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/sys/unix/uds/socketaddr.rs b/src/sys/unix/uds/socketaddr.rs
index a9f9ea9..4c7c411 100644
--- a/src/sys/unix/uds/socketaddr.rs
+++ b/src/sys/unix/uds/socketaddr.rs
@@ -78,14 +78,8 @@ cfg_os_poll! {
/// Documentation reflected in [`SocketAddr`]
///
/// [`SocketAddr`]: std::os::unix::net::SocketAddr
- // FIXME: The matches macro requires rust 1.42.0 and we still support 1.39.0
- #[allow(clippy::match_like_matches_macro)]
pub fn is_unnamed(&self) -> bool {
- if let AddressKind::Unnamed = self.address() {
- true
- } else {
- false
- }
+ matches!(self.address(), AddressKind::Unnamed)
}
/// Returns the contents of this address if it is a `pathname` address.
@@ -100,6 +94,18 @@ cfg_os_poll! {
None
}
}
+
+ /// Returns the contents of this address if it is an abstract namespace
+ /// without the leading null byte.
+ // Link to std::os::unix::net::SocketAddr pending
+ // https://github.com/rust-lang/rust/issues/85410.
+ pub fn as_abstract_namespace(&self) -> Option<&[u8]> {
+ if let AddressKind::Abstract(path) = self.address() {
+ Some(path)
+ } else {
+ None
+ }
+ }
}
}