Skip to content

Commit 5746e46

Browse files
committed
Document AddressFamily and SockType
1 parent e7d4720 commit 5746e46

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/sys/socket/addr.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,41 @@ use std::os::unix::io::RawFd;
1212
#[cfg(any(target_os = "ios", target_os = "macos"))]
1313
use ::sys::socket::addr::sys_control::SysControlAddr;
1414

15+
/// These constants specify the protocol family to be used
16+
/// in [`socket`](fn.socket.html) and [`socketpair`](fn.socketpair.html)
1517
#[repr(i32)]
1618
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
1719
pub enum AddressFamily {
20+
/// Local communication (see [`unix(7)`](http://man7.org/linux/man-pages/man7/unix.7.html))
1821
Unix = libc::AF_UNIX,
22+
/// IPv4 Internet protocols (see [`ip(7)`](http://man7.org/linux/man-pages/man7/ip.7.html))
1923
Inet = libc::AF_INET,
24+
/// IPv6 Internet protocols (see [`ipv6(7)`](http://man7.org/linux/man-pages/man7/ipv6.7.html))
2025
Inet6 = libc::AF_INET6,
26+
/// Kernel user interface device (see [`netlink(7)`](http://man7.org/linux/man-pages/man7/netlink.7.html))
2127
#[cfg(any(target_os = "android", target_os = "linux"))]
2228
Netlink = libc::AF_NETLINK,
29+
/// Low level packet interface (see [`packet(7)`](http://man7.org/linux/man-pages/man7/packet.7.html))
2330
#[cfg(any(target_os = "android", target_os = "linux"))]
2431
Packet = libc::AF_PACKET,
32+
/// KEXT Controls and Notifications
2533
#[cfg(any(target_os = "ios", target_os = "macos"))]
2634
System = libc::AF_SYSTEM,
35+
/// Amateur radio AX.25 protocol
2736
#[cfg(any(target_os = "android", target_os = "linux"))]
2837
Ax25 = libc::AF_AX25,
38+
/// IPX - Novell protocols
2939
Ipx = libc::AF_IPX,
40+
/// AppleTalk
3041
AppleTalk = libc::AF_APPLETALK,
3142
#[cfg(any(target_os = "android", target_os = "linux"))]
3243
NetRom = libc::AF_NETROM,
3344
#[cfg(any(target_os = "android", target_os = "linux"))]
3445
Bridge = libc::AF_BRIDGE,
46+
/// Access to raw ATM PVCs
3547
#[cfg(any(target_os = "android", target_os = "linux"))]
3648
AtmPvc = libc::AF_ATMPVC,
49+
/// ITU-T X.25 / ISO-8208 protocol (see [`x25(7)`](http://man7.org/linux/man-pages/man7/x25.7.html))
3750
#[cfg(any(target_os = "android", target_os = "linux"))]
3851
X25 = libc::AF_X25,
3952
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -83,6 +96,7 @@ pub enum AddressFamily {
8396
Ieee802154 = libc::AF_IEEE802154,
8497
#[cfg(any(target_os = "android", target_os = "linux"))]
8598
Caif = libc::AF_CAIF,
99+
/// Interface to kernel crypto API
86100
#[cfg(any(target_os = "android", target_os = "linux"))]
87101
Alg = libc::AF_ALG,
88102
#[cfg(target_os = "linux")]

src/sys/socket/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,27 @@ pub use self::multicast::{
5151

5252
pub use libc::sockaddr_storage;
5353

54+
/// These constants are used to specify the communication semantics
55+
/// when creating a socket with [`socket()`](fn.socket.html)
5456
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
5557
#[repr(i32)]
5658
pub enum SockType {
59+
/// Provides sequenced, reliable, two-way, connection-
60+
/// based byte streams. An out-of-band data transmission
61+
/// mechanism may be supported.
5762
Stream = libc::SOCK_STREAM,
63+
/// Supports datagrams (connectionless, unreliable
64+
/// messages of a fixed maximum length).
5865
Datagram = libc::SOCK_DGRAM,
66+
/// Provides a sequenced, reliable, two-way connection-
67+
/// based data transmission path for datagrams of fixed
68+
/// maximum length; a consumer is required to read an
69+
/// entire packet with each input system call.
5970
SeqPacket = libc::SOCK_SEQPACKET,
71+
/// Provides raw network protocol access.
6072
Raw = libc::SOCK_RAW,
73+
/// Provides a reliable datagram layer that does not
74+
/// guarantee ordering.
6175
Rdm = libc::SOCK_RDM,
6276
}
6377

0 commit comments

Comments
 (0)