diff --git a/Cargo.toml b/Cargo.toml index 7c96a0c..4c7127b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,9 +6,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rustix = { version = "0.36.3", default-features = false, features = [ +rustix = { version = "0.38.8", default-features = false, features = [ + "event", "fs", "net", + "pipe", "std", ] } diff --git a/src/io.rs b/src/io.rs index ce8582e..f6482f4 100644 --- a/src/io.rs +++ b/src/io.rs @@ -1,5 +1,5 @@ use crate::Readiness; -use rustix::{fd::AsFd, io::PollFd}; +use rustix::{event::PollFd, fd::AsFd}; use std::num::NonZeroUsize; pub use std::io::{Error, Result}; @@ -54,7 +54,7 @@ impl From for usize { pub fn try_ready(fd: &A, interest: Readiness) -> Result> { let mut fds = [PollFd::new(fd, interest.into())]; - rustix::io::poll(&mut fds, 0)?; + rustix::event::poll(&mut fds, 0)?; let revents: Readiness = fds[0].revents().into(); let out = revents & interest; diff --git a/src/lib.rs b/src/lib.rs index 3f90a28..d7ab6dd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,7 @@ -use rustix::io::{PipeFlags, PollFd, PollFlags}; +use rustix::{ + event::{PollFd, PollFlags}, + pipe::PipeFlags, +}; use std::{ borrow::Borrow, collections::HashMap, @@ -66,7 +69,7 @@ pub struct NotifyToken { } pub fn notify_pair() -> io::Result<(Notify, NotifyToken)> { - let (registered, free) = rustix::io::pipe_with(PipeFlags::NONBLOCK | PipeFlags::CLOEXEC)?; + let (registered, free) = rustix::pipe::pipe_with(PipeFlags::NONBLOCK | PipeFlags::CLOEXEC)?; Ok(( Notify { registered }, @@ -377,7 +380,7 @@ impl<'a> Poller<'a> { pub fn poll(mut self) -> io::Result> { let timeout = self.timeout.unwrap_or(-1); - let n = rustix::io::poll(&mut self.fds, timeout)?; + let n = rustix::event::poll(&mut self.fds, timeout)?; Ok(self .fds diff --git a/src/net.rs b/src/net.rs index 7910366..5232c99 100644 --- a/src/net.rs +++ b/src/net.rs @@ -1,10 +1,7 @@ use crate::io::{in_progress, nonblocking, InProgress, Nonblocking, ReadBytes, Result}; use rustix::{ fd::{AsFd, OwnedFd}, - net::{ - AcceptFlags, AddressFamily, Protocol, RecvFlags, SendFlags, SocketAddrAny, SocketFlags, - SocketType, - }, + net::{AddressFamily, RecvFlags, SendFlags, SocketAddrAny, SocketFlags, SocketType}, }; use std::net::{IpAddr, SocketAddr}; @@ -49,7 +46,7 @@ impl UdpSocket { family, SocketType::DGRAM, SocketFlags::NONBLOCK | SocketFlags::CLOEXEC, - Protocol::UDP, + Some(rustix::net::ipproto::UDP), )?; rustix::net::sockopt::set_socket_reuseaddr(&sock, true)?; @@ -105,7 +102,7 @@ impl UdpSocketBuilder { impl TcpListener { pub fn try_accept(&self) -> Result)>> { nonblocking( - rustix::net::acceptfrom_with(&self.fd, AcceptFlags::NONBLOCK | AcceptFlags::CLOEXEC) + rustix::net::acceptfrom_with(&self.fd, SocketFlags::NONBLOCK | SocketFlags::CLOEXEC) .map(|(fd, addr)| { ( TcpStream { fd }, @@ -136,7 +133,7 @@ impl TcpListener { family, SocketType::STREAM, SocketFlags::NONBLOCK | SocketFlags::CLOEXEC, - Protocol::TCP, + Some(rustix::net::ipproto::TCP), )?; rustix::net::sockopt::set_socket_reuseaddr(&sock, true)?; @@ -169,7 +166,7 @@ impl TcpStream { family, SocketType::STREAM, SocketFlags::NONBLOCK | SocketFlags::CLOEXEC, - Protocol::TCP, + Some(rustix::net::ipproto::TCP), )?; Ok(TcpStreamBuilder {