netsim 0.3.0

Run tests in network-isolated threads. Intercept and meddle with their packets.
Documentation
pub(crate) use {
    std::{
        cmp, fmt, io, mem, panic, ptr, slice, task, thread, str,
        collections::{VecDeque, hash_map, HashMap, BTreeMap, HashSet},
        ffi::{CStr, CString},
        future::{Future, IntoFuture},
        fs::File,
        io::Write,
        mem::MaybeUninit,
        net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddrV4},
        os::fd::{OwnedFd, FromRawFd, AsRawFd},
        pin::Pin,
        sync::Arc,
        task::Poll,
        time::{Duration, Instant},
    },
    bytes::BytesMut,
    libc::{c_int, c_long, c_void, pid_t},
    tokio::io::unix::AsyncFd,
    futures::{
        ready, FutureExt, Sink, Stream, StreamExt,
        stream::FusedStream,
        channel::mpsc,
    },
    ioctl_sys::ioctl,
    pin_project::pin_project,
    rand::Rng,
    log::{log_enabled, debug, Level},
    netsim_macros::{ipv4_network, ipv6_network},
    crate::{
        namespace, ioctl, iface, adapter, sys,
        device::IpChannel,
        machine::Machine,
        iface::{
            create::IpIfaceBuilder,
            stream::{IpIface, IpSinkStream},
        },
        network::{Ipv4Network, Ipv6Network},
        packet::{
            IpPacket, IpPacketVersion, Ipv4PacketProtocol, Tcpv4Packet, TcpPacketFlags,
        },
    },
};

#[cfg(test)]
pub(crate) use {
    net_literals::{ipv4, addrv4},
    tokio::{
        io::{AsyncReadExt, AsyncWriteExt},
        net::{TcpStream, TcpListener},
    },
    futures::{join, SinkExt},
    crate::{
        device::{BiChannel, IpHub, NatBuilder},
        SinkStreamExt,
    },
};