File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,33 @@ impl SocketAddr {
67
67
pub fn as_pathname ( & self ) -> Option < & Path > {
68
68
None
69
69
}
70
+
71
+ /// Returns true if and only if the address is unnamed.
72
+ ///
73
+ /// # Examples
74
+ ///
75
+ /// A named address:
76
+ ///
77
+ /// ```no_run
78
+ /// use std::os::unix::net::UnixListener;
79
+ ///
80
+ /// let socket = UnixListener::bind("/tmp/sock").unwrap();
81
+ /// let addr = socket.local_addr().expect("Couldn't get local address");
82
+ /// assert_eq!(addr.is_unnamed(), false);
83
+ /// ```
84
+ ///
85
+ /// An unnamed address:
86
+ ///
87
+ /// ```
88
+ /// use std::os::unix::net::UnixDatagram;
89
+ ///
90
+ /// let socket = UnixDatagram::unbound().unwrap();
91
+ /// let addr = socket.local_addr().expect("Couldn't get local address");
92
+ /// assert_eq!(addr.is_unnamed(), true);
93
+ /// ```
94
+ pub fn is_unnamed ( & self ) -> bool {
95
+ false
96
+ }
70
97
}
71
98
impl fmt:: Debug for SocketAddr {
72
99
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
You can’t perform that action at this time.
0 commit comments