interprocess_docfix/lib.rs
1//! Interprocess communication toolkit for Rust programs. The crate aims to expose as many platform-specific features as possible while maintaining a uniform interface for all platforms.
2//!
3//! # Features
4//! ## Interprocess communication primitives
5//! `interprocess` provides both OS-specific interfaces for IPC and cross-platform abstractions for them.
6//!
7//! ### Cross-platform IPC APIs
8//! - **Local sockets** – similar to TCP sockets, but use filesystem or namespaced paths instead of ports on `localhost`, depending on the OS, bypassing the network stack entirely; implemented using named pipes on Windows and Unix domain sockets on Unix
9//!
10//! ### Platform-specific, but present on both Unix-like systems and Windows
11//! - **Unnamed pipes** – anonymous file-like objects for communicating privately in one direction, most commonly used to communicate between a child process and its parent
12//! - **Signals** – C signals on Windows, POSIX signals on Unix-like OSes *(deprecated)*
13//!
14//! ### Unix-only
15//! - **FIFO files** – special type of file which is similar to unnamed pipes but exists on the filesystem, often referred to as "named pipes" but completely different from Windows named pipes
16//! - **Unix domain sockets** – a type of socket which is built around the standard networking APIs but uses filesystem paths instead of ports on `localhost`, optionally using a spearate namespace on Linux akin to Windows named pipes
17//!
18//! ### Windows-only
19//! - **Named pipes** – closely resembles Unix domain sockets, uses a separate namespace instead of on-drive paths
20//!
21//! ## Asynchronous I/O
22//! Currently, only Tokio for local sockets, Unix domain sockets and Windows named pipes is supported. Support for `async-std` is planned.
23//!
24//! # Feature gates
25//! - **`signals`**, *on* by default – enables support for POSIX signals and C signals. Pulls in additional dependencies.
26//! - **`tokio_support`**, *off* by default – enables support for Tokio-powered efficient asynchronous IPC. Cannot simply be named `tokio` because of Cargo limitations.
27//! - **`nonblocking`**, *on* by default – deprecated and will be removed, do not use.
28//!
29//! # License
30//! This crate, along with all community contributions made to it, is dual-licensed under the terms of either the [MIT license] or the [Apache 2.0 license].
31//!
32//! [MIT license]: https://choosealicense.com/licenses/mit/ " "
33//! [Apache 2.0 license]: https://choosealicense.com/licenses/apache-2.0/ " "
34// TODO mailslots
35// TODO shared memory
36// TODO use standard library raw+owned FDs and handles
37// TODO the Intra Doc Link Sweep
38// - **Mailslots** – Windows-specific interprocess communication primitive for short messages, potentially even across the network
39// - **Shared memory** – exposes a nice safe interface for shared memory based on mapping identifiers, with some additional platform-specific extensions
40
41#![cfg_attr(feature = "doc_cfg", feature(doc_cfg))]
42#![deny(rust_2018_idioms)]
43#![warn(missing_docs)]
44#![allow(clippy::nonstandard_macro_braces)]
45#![cfg_attr(
46 unsafe_op_in_unsafe_fn_stable, // This is set by the build script on Rust 1.52+
47 forbid(unsafe_op_in_unsafe_fn),
48)]
49#![cfg_attr(not(unsafe_op_in_unsafe_fn_stable), allow(unused_unsafe))]
50
51// If an operating system is not listed here, the `compile_error!` is invoked
52#[cfg(not(any(
53 // "Linux-like" (src/unix/linux_like/mod.rs in libc)
54 target_os = "linux",
55 target_os = "android",
56 target_os = "emscripten",
57
58 // Windows. There is just one.
59 target_os = "windows",
60
61 // "BSD-like" (src/unix/bsd/mod.rs in libc)
62 target_os = "freebsd",
63 target_os = "openbsd",
64 target_os = "netbsd",
65 target_os = "dragonfly",
66 target_os = "macos",
67 target_os = "ios",
68
69 // "Solarish" (src/unix/solarish/mod.rs in libc)
70 target_os = "solaris",
71 target_os = "illumos",
72
73 // Haiku (src/unix/haiku/mod.rs in libc)
74 target_os = "haiku",
75
76 // Hermit (src/unix/hermit/mod.rs in libc)
77 target_os = "hermit",
78
79 // Redox (src/unix/redox/mod.rs in libc)
80 target_os = "redox",
81)))]
82compile_error!("Your target operating system is not supported by interprocess – check if yours is in the list of supported systems, and if not, please open an issue on the GitHub repository if you think that it should be included");
83
84#[cfg(not(any(target_pointer_width = "32", target_pointer_width = "64")))]
85compile_error!("Platforms with exotic pointer widths (neither 32-bit nor 64-bit) are not supported by interprocess – if you think that your specific case needs to be accounted for, please open an issue on the GitHub repository");
86
87#[macro_use]
88mod macros;
89
90pub mod local_socket;
91#[cfg(any(doc, feature = "nonblocking"))]
92#[cfg_attr(feature = "doc_cfg", doc(cfg(feature = "nonblocking")))]
93#[deprecated(note = "\
94does not integrate with async runtimes, leading to poor performance and bugs related to reading \
95and writing at the same time (you can't) – see the `tokio` modules for relevant IPC primitives \
96or open an issue if you want more async runtimes to be supported as well")]
97pub mod nonblocking;
98pub mod unnamed_pipe;
99//pub mod shared_memory;
100
101pub mod os;
102
103mod sealed;
104pub(crate) use sealed::Sealed;
105
106mod reliable_read_msg;
107pub use reliable_read_msg::*;