use std::fmt;
use socket2::{SockAddr, Socket};
use windows_sys::Win32::System::IO::OVERLAPPED;
mod connect;
mod driver;
mod io;
mod ops;
mod stream;
pub use self::driver::{Driver, DriverApi, Handler};
struct TcpStream(Socket, SockAddr, stream::StreamOps);
struct UnixStream(Socket, SockAddr, stream::StreamOps);
#[repr(C)]
pub struct Overlapped {
pub(crate) base: OVERLAPPED,
pub(crate) hnd: u32,
pub(crate) udata: u32,
}
impl Overlapped {
pub(crate) fn new(hnd: u32, udata: u32) -> Self {
Self {
hnd,
udata,
base: unsafe { std::mem::zeroed() },
}
}
pub fn as_overlapped(&self) -> *mut OVERLAPPED {
(&raw const self.base).cast_mut()
}
pub fn user_data(&self) -> u32 {
self.udata
}
}
impl fmt::Debug for Overlapped {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Overlapped")
.field("base", &"OVERLAPPED")
.field("hnd", &self.hnd)
.field("udata", &self.udata)
.finish()
}
}