We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 828d2a8 commit dddb455Copy full SHA for dddb455
src/types/socket_info.rs
@@ -41,3 +41,21 @@ pub struct UdpSocketInfo {
41
pub local_addr: IpAddr,
42
pub local_port: u16,
43
}
44
+
45
+impl SocketInfo {
46
+ /// Local address of this socket.
47
+ pub fn local_addr(&self) -> IpAddr {
48
+ match &self.protocol_socket_info {
49
+ ProtocolSocketInfo::Tcp(s) => s.local_addr,
50
+ ProtocolSocketInfo::Udp(s) => s.local_addr,
51
+ }
52
53
54
+ /// Local port of this socket.
55
+ pub fn local_port(&self) -> u16 {
56
57
+ ProtocolSocketInfo::Tcp(s) => s.local_port,
58
+ ProtocolSocketInfo::Udp(s) => s.local_port,
59
60
61
+}
0 commit comments