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 55 56 57 58 59 60 61 62 63 64 65
//! Cross-platform socketpair functionality
//!
//! A socketpair stream is a bidirectional bytestream. The `socketpair_stream`
//! function creates a pair of `SocketpairStream` objects connected to opposite
//! ends of a stream, and both can be written to and read from.
//!
//! ```rust
//! use socketpair::socketpair_stream;
//! use std::io::{self, Read, Write};
//! use std::thread;
//!
//! fn main() -> anyhow::Result<()> {
//! let (mut a, mut b) = socketpair_stream()?;
//!
//! let _t = thread::spawn(move || -> io::Result<()> { writeln!(a, "hello world") });
//!
//! let mut buf = String::new();
//! b.read_to_string(&mut buf)?;
//! assert_eq!(buf, "hello world\n");
//!
//! Ok(())
//! }
//! ```
#![deny(missing_docs)]
#![cfg_attr(can_vector, feature(can_vector))]
#![cfg_attr(all(unix, unix_socket_peek), feature(unix_socket_peek))]
#![cfg_attr(write_all_vectored, feature(write_all_vectored))]
#![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
#[cfg(not(windows))]
mod rustix;
/*
#[cfg(all(unix, feature = "async-std"))]
mod unix_async_std;
#[cfg(all(unix, feature = "tokio"))]
mod unix_tokio;
*/
#[cfg(windows)]
mod windows;
/*
#[cfg(all(windows, feature = "async-std"))]
mod windows_async_std;
#[cfg(all(windows, feature = "tokio"))]
mod windows_tokio;
*/
#[cfg(all(unix, not(any(target_os = "ios", target_os = "macos"))))]
pub use crate::rustix::socketpair_seqpacket;
#[cfg(unix)]
pub use crate::rustix::{socketpair_stream, SocketpairStream};
/*
#[cfg(all(unix, feature = "async-std"))]
pub use crate::unix_async_std::{async_std_socketpair_stream, AsyncStdSocketpairStream};
#[cfg(all(unix, feature = "tokio"))]
pub use crate::unix_tokio::{tokio_socketpair_stream, TokioSocketpairStream};
*/
#[cfg(windows)]
pub use crate::windows::{socketpair_seqpacket, socketpair_stream, SocketpairStream};
/*
#[cfg(all(windows, feature = "async-std"))]
pub use crate::windows_async_std::{async_std_socketpair_stream, AsyncStdSocketpairStream};
#[cfg(all(windows, feature = "tokio"))]
pub use crate::windows_tokio::{tokio_socketpair_stream, TokioSocketpairStream};
*/