1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Cross-platform file descriptor / handle passing for roam.
//!
//! This crate provides a unified API for passing file descriptors (Unix) or
//! socket handles (Windows) between processes over IPC channels.
//!
//! # Platform implementations
//!
//! - **Unix**: Uses SCM_RIGHTS to pass raw file descriptors over Unix domain sockets
//! - **Windows**: Uses `WSADuplicateSocket` to serialize socket state, sends it over
//! a named pipe, and recreates the socket with `WSASocket` on the receiving end
//!
//! # Usage
//!
//! ## Unix
//!
//! ```ignore
//! use roam_fdpass::{send_fd, recv_fd};
//! use tokio::net::UnixStream;
//!
//! // Sender
//! let tcp_listener = std::net::TcpListener::bind("127.0.0.1:0")?;
//! let fd = tcp_listener.into_raw_fd();
//! send_fd(&unix_stream, fd).await?;
//!
//! // Receiver
//! let fd = recv_fd(&unix_stream).await?;
//! let listener = unsafe { std::net::TcpListener::from_raw_fd(fd) };
//! ```
//!
//! ## Windows
//!
//! ```ignore
//! use roam_fdpass::{send_socket, recv_socket};
//! use tokio::net::windows::named_pipe::{NamedPipeServer, NamedPipeClient};
//!
//! // Sender (needs receiver's process ID)
//! let tcp_listener = std::net::TcpListener::bind("127.0.0.1:0")?;
//! send_socket(&pipe, &tcp_listener, receiver_pid).await?;
//!
//! // Receiver
//! let listener: std::net::TcpListener = recv_socket(&pipe).await?;
//! ```
pub use *;
pub use *;