turmoil/net/
mod.rs

1//! This module contains the simulated TCP/UDP networking types.
2//!
3//! They mirror [tokio::net](https://docs.rs/tokio/latest/tokio/net/) to provide
4//! a high fidelity implementation.
5
6use std::net::SocketAddr;
7
8pub mod tcp;
9pub use tcp::{listener::TcpListener, stream::TcpStream};
10
11pub(crate) mod udp;
12pub use udp::UdpSocket;
13
14#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
15pub(crate) struct SocketPair {
16    pub(crate) local: SocketAddr,
17    pub(crate) remote: SocketAddr,
18}
19
20impl SocketPair {
21    pub(crate) fn new(local: SocketAddr, remote: SocketAddr) -> SocketPair {
22        assert_ne!(local, remote);
23        SocketPair { local, remote }
24    }
25}