1#![cfg_attr(any(target_os="illumos", target_os="solaris", target_os="windows"), allow(unused))]
23
24#![allow(
25 clippy::cast_lossless, clippy::unnecessary_cast, clippy::len_zero, clippy::needless_return, clippy::redundant_closure, clippy::needless_lifetimes, clippy::needless_borrow, clippy::bool_to_int_with_if, )]
35
36#[cfg(target_family = "unix")]
37extern crate libc;
38
39#[cfg(target_family = "windows")]
40extern crate windows_sys;
41
42macro_rules! cvt {($syscall:expr) => {
44 match $syscall
45 {
46 -1 => Err(io::Error::last_os_error()),
47 ok => Ok(ok),
48 }
49}}
50
51macro_rules! cvt_r {($syscall:expr) => {
53 loop
54 {
55 let result = $syscall;
56 if result != -1
57 {
58 break Ok(result);
59 }
60
61 let err = io::Error::last_os_error();
62
63 if err.kind() != std::io::ErrorKind::Interrupted
64 {
65 break Err(err);
66 }
67 }
68}}
69
70#[cfg(target_family = "windows")]
71mod windows_unixstream;
72
73mod addr;
74
75#[cfg(target_family = "unix")]
76mod credentials;
77
78#[cfg(target_family = "unix")]
79mod helpers;
80
81#[cfg(target_family = "unix")]
82mod ancillary;
83
84#[cfg(target_family = "unix")]
85mod traits;
86
87#[cfg(target_family = "unix")]
88mod seqpacket;
89
90
91pub(crate) const LISTEN_BACKLOG: std::ffi::c_int = 128;pub use addr::{UnixSocketAddr, UnixSocketAddrRef, AddrName};
95
96#[cfg(windows)]
97pub use windows_unixstream::{WindowsUnixListener, WindowsUnixStream, RecvFlags};
98
99#[cfg(windows)]
100pub use windows_unixstream::{get_socket_family, get_socket_type};
101
102#[cfg(target_family = "unix")]
103pub use traits::{UnixListenerExt, UnixStreamExt, UnixDatagramExt};
104
105#[cfg(target_family = "unix")]
106pub use seqpacket::{UnixSeqpacketListener, UnixSeqpacketConn};
107
108#[cfg(target_family = "unix")]
109pub use credentials::ConnCredentials;
110
111#[cfg(target_family = "unix")]
112pub mod nonblocking {
113 pub use crate::seqpacket::NonblockingUnixSeqpacketListener as UnixSeqpacketListener;
114 pub use crate::seqpacket::NonblockingUnixSeqpacketConn as UnixSeqpacketConn;
115}
116
117#[cfg(debug_assertions)]
118mod doctest_md_files {
119 macro_rules! mdfile {($content:expr, $(#[$meta:meta])* $attach_to:ident) => {
120 #[doc=$content]
121 #[allow(unused)]
122 $(#[$meta])* enum $attach_to {}
124 }}
125 mdfile!{
126 include_str!("../README.md"),
127 #[cfg(any(target_os="linux", target_os="android"))] Readme
129 }
130}