//! Support for file descriptor passing with `LISTEN_FD`
//!
//! The entrypoints of this module are [`FileDescriptor::receive()`] and [`FileDescriptor::receive_with_names()`]. (And their **`unsafe`** `*_no_dup` variants.)
/// If this is an FD provided by a .socket unit it corresponds to `ListenSpecial=`.
File(File),
/// The file descriptor is a directory.
Directory(OwnedFd),
/// The file descriptor is a FIFO
///
/// If this is an FD provided by a .socket unit it corresponds to `ListenFIFO=`
Fifo(File),
/// The file descriptor is a TCP socket listening for incoming connexions.
///
/// If this is an FD provided by a .socket unit it corresponds to `ListenStream=` with an IP address.
TcpListener(TcpListener),
/// The file descriptor is a TCP socket that doesn't listen for incoming connexions.
TcpStream(TcpStream),
/// The file descriptor is an UDP .
///
/// If this is an FD provided by a .socket unit it corresponds to `ListenDatagram=` with an IP address.
UdpSocket(UdpSocket),
/// The file descriptor is another inet socket
///
/// You should figure out what exactly it is before you use it.
InetOther(OwnedFd),
/// The file descriptor is a Unix Stream Socket listening for incoming connexions.
///
/// If this is an FD provided by a .socket unit it corresponds to `ListenStream=` with a path or starting with `@` (abstract socket).
UnixListener(UnixListener),
/// The file descriptor is a Unix Stream Socket.
UnixStream(UnixStream),
/// The file descriptor is a Unix Datagram Socket.
///
/// If this is an FD provided by a .socket unit it corresponds to `ListenDatagram=` with a path or starting with `@` (abstract socket).
UnixDatagram(UnixDatagram),
/// The file descriptor is a Unix SEQPACKET Socket.
///
/// If this is an FD provided by a .socket unit it corresponds to `ListenSequentialPacket=`
UnixSequentialPaquet(OwnedFd),
/// The file descriptor is another type of Unix Socket.
UnixOther(OwnedFd),
/// The file descriptor is some other socket type.
///
/// Probably a Netlink family socket if from a .socket unit but you should check yourself.
SocketOther(OwnedFd),
/// The file descriptor is a message queue.
///
/// If this is an FD provided by a .socket unit it corresponds to `ListenMessageQueue=`
MessageQueue(OwnedFd),
/// The file descriptor is something else.
Other(OwnedFd),
}
implFileDescriptor{
/// Get any file descriptor passed by systemd or anything implementing the `LISTEN_FD` protocol.
///
/// This isn't necessarily limited to File descriptor of listening sockets, IPCs or FIFOs but also anything that is in the file descriptor store.
///
/// The file descriptors are duplicated using [`fcntl_dupfd_cloexec`](rustix::fs::fcntl_dupfd_cloexec) so they can safely be used from rust and will not be propagated to children process automatically.
/// Get any file descriptor passed by systemd or anything implementing the `LISTEN_FD` protocol.
///
/// This isn't necessarily limited to File descriptor of listening sockets, IPCs or FIFOs but also anything that is in the file descriptor store.
///
/// The file descriptors are taken directly as [`OwnedFd`]s instead of being duplicated. In order to limit unsoundness this function therefore always unset the environment.
/// Get any file descriptor passed using `LISTEN_FD` and their names.
///
/// This isn't necessarily limited to File descriptor of listening sockets, IPCs or FIFOs but also anything that is in the file descriptor store.
///
/// The file descriptors are duplicated using [`fcntl_dupfd_cloexec`](rustix::fs::fcntl_dupfd_cloexec) so they can safely be used from rust and will not be propagated to children process automatically.
///
/// # Errors
///
/// This function will fail if no file descriptors could be obtained or the names associated with them couldn't be obtained. See [`ReceiveNameError`] for details.
/// Get any file descriptor passed using `LISTEN_FD` and their names.
///
/// This isn't necessarily limited to File descriptor of listening sockets, IPCs or FIFOs but also anything that is in the file descriptor store.
///
/// The file descriptors are taken directly as [`OwnedFd`]s instead of being duplicated. In order to limit unsoundness this function therefore always unset the environment.
///
/// # Errors
///
/// This function will fail if no file descriptors could be obtained or the names associated with them couldn't be obtained. See [`ReceiveNameError`] for details.