interprocess/lib.rs
1#![doc = include_str!("../README.md")]
2#![cfg_attr(feature = "doc_cfg", feature(doc_cfg))]
3// If this was in Cargo.toml, it would cover examples as well
4#![warn(
5 missing_docs,
6 clippy::panic_in_result_fn,
7 clippy::missing_assert_message,
8 clippy::indexing_slicing,
9 clippy::arithmetic_side_effects
10)]
11
12mod platform_check;
13
14// TODO inspect panic points
15
16#[macro_use]
17mod macros;
18
19pub mod bound_util;
20pub mod error;
21pub mod local_socket;
22pub mod unnamed_pipe;
23
24/// Platform-specific functionality for various interprocess communication primitives.
25///
26/// This module houses two modules: `unix` and `windows`, although only one at a time will be
27/// visible, depending on which platform the documentation was built on. If you're using
28/// [Docs.rs](https://docs.rs/interprocess/latest/interprocess), you can view the documentation for
29/// Windows, macOS, Linux and FreeBSD using the Platform menu on the Docs.rs-specific header bar at
30/// the top of the page. Docs.rs builds also have the nightly-only `doc_cfg` feature enabled by
31/// default, with which everything platform-specific has a badge next to it which specifies the
32/// `cfg(...)` conditions for that item to be available.
33pub mod os {
34 #[cfg(unix)]
35 #[cfg_attr(feature = "doc_cfg", doc(cfg(unix)))]
36 pub mod unix;
37 #[cfg(windows)]
38 #[cfg_attr(feature = "doc_cfg", doc(cfg(windows)))]
39 pub mod windows;
40}
41
42/// Describes how a client connection operation should wait for the server to accept it.
43#[derive(Copy, Clone, Debug, Default)]
44pub enum ConnectWaitMode {
45 /// The connection operation returns immediately. Subsequent I/O operations will block until
46 /// the connection actually becomes established. If a connection error occurs in the
47 /// background, that error will be returned by the next I/O operation on the returned object.
48 Deferred,
49 /// A wait state is entered until the connection becomes established which lasts for up to the
50 /// given amount of time. An error of kind [`TimedOut`](std::io::ErrorKind::WouldBlock) is
51 /// returned if it does not become established within that timeframe.
52 Timeout(std::time::Duration),
53 /// A wait state is entered until the connection becomes established. This wait state may
54 /// last for an indefinite amount of time.
55 #[default]
56 Unbounded,
57}
58impl ConnectWaitMode {
59 fn timeout_or_unsupported(self, emsg: &str) -> std::io::Result<Option<std::time::Duration>> {
60 match self {
61 Self::Deferred => Err(std::io::Error::new(std::io::ErrorKind::Unsupported, emsg)),
62 Self::Timeout(t) => Ok(Some(t)),
63 Self::Unbounded => Ok(None),
64 }
65 }
66}
67
68mod try_clone;
69pub use try_clone::*;
70
71mod atomic_enum;
72mod misc;
73pub(crate) use {atomic_enum::*, misc::*};
74
75#[cfg(test)]
76#[path = "../tests/index.rs"]
77#[allow(clippy::unwrap_used, clippy::arithmetic_side_effects, clippy::indexing_slicing)]
78mod tests;