Update rustix
This commit is contained in:
parent
32e103a470
commit
e16509cc8f
|
@ -6,9 +6,11 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustix = { version = "0.36.3", default-features = false, features = [
|
rustix = { version = "0.38.8", default-features = false, features = [
|
||||||
|
"event",
|
||||||
"fs",
|
"fs",
|
||||||
"net",
|
"net",
|
||||||
|
"pipe",
|
||||||
"std",
|
"std",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::Readiness;
|
use crate::Readiness;
|
||||||
use rustix::{fd::AsFd, io::PollFd};
|
use rustix::{event::PollFd, fd::AsFd};
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
|
|
||||||
pub use std::io::{Error, Result};
|
pub use std::io::{Error, Result};
|
||||||
|
@ -54,7 +54,7 @@ impl From<ReadBytes> for usize {
|
||||||
|
|
||||||
pub fn try_ready<A: AsFd>(fd: &A, interest: Readiness) -> Result<Nonblocking<Readiness>> {
|
pub fn try_ready<A: AsFd>(fd: &A, interest: Readiness) -> Result<Nonblocking<Readiness>> {
|
||||||
let mut fds = [PollFd::new(fd, interest.into())];
|
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 revents: Readiness = fds[0].revents().into();
|
||||||
|
|
||||||
let out = revents & interest;
|
let out = revents & interest;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
use rustix::io::{PipeFlags, PollFd, PollFlags};
|
use rustix::{
|
||||||
|
event::{PollFd, PollFlags},
|
||||||
|
pipe::PipeFlags,
|
||||||
|
};
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Borrow,
|
borrow::Borrow,
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
|
@ -66,7 +69,7 @@ pub struct NotifyToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn notify_pair() -> io::Result<(Notify, 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((
|
Ok((
|
||||||
Notify { registered },
|
Notify { registered },
|
||||||
|
@ -377,7 +380,7 @@ impl<'a> Poller<'a> {
|
||||||
pub fn poll(mut self) -> io::Result<Vec<(usize, Readiness)>> {
|
pub fn poll(mut self) -> io::Result<Vec<(usize, Readiness)>> {
|
||||||
let timeout = self.timeout.unwrap_or(-1);
|
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
|
Ok(self
|
||||||
.fds
|
.fds
|
||||||
|
|
13
src/net.rs
13
src/net.rs
|
@ -1,10 +1,7 @@
|
||||||
use crate::io::{in_progress, nonblocking, InProgress, Nonblocking, ReadBytes, Result};
|
use crate::io::{in_progress, nonblocking, InProgress, Nonblocking, ReadBytes, Result};
|
||||||
use rustix::{
|
use rustix::{
|
||||||
fd::{AsFd, OwnedFd},
|
fd::{AsFd, OwnedFd},
|
||||||
net::{
|
net::{AddressFamily, RecvFlags, SendFlags, SocketAddrAny, SocketFlags, SocketType},
|
||||||
AcceptFlags, AddressFamily, Protocol, RecvFlags, SendFlags, SocketAddrAny, SocketFlags,
|
|
||||||
SocketType,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use std::net::{IpAddr, SocketAddr};
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
|
@ -49,7 +46,7 @@ impl UdpSocket {
|
||||||
family,
|
family,
|
||||||
SocketType::DGRAM,
|
SocketType::DGRAM,
|
||||||
SocketFlags::NONBLOCK | SocketFlags::CLOEXEC,
|
SocketFlags::NONBLOCK | SocketFlags::CLOEXEC,
|
||||||
Protocol::UDP,
|
Some(rustix::net::ipproto::UDP),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
rustix::net::sockopt::set_socket_reuseaddr(&sock, true)?;
|
rustix::net::sockopt::set_socket_reuseaddr(&sock, true)?;
|
||||||
|
@ -105,7 +102,7 @@ impl UdpSocketBuilder {
|
||||||
impl TcpListener {
|
impl TcpListener {
|
||||||
pub fn try_accept(&self) -> Result<Nonblocking<(TcpStream, Option<SocketAddr>)>> {
|
pub fn try_accept(&self) -> Result<Nonblocking<(TcpStream, Option<SocketAddr>)>> {
|
||||||
nonblocking(
|
nonblocking(
|
||||||
rustix::net::acceptfrom_with(&self.fd, AcceptFlags::NONBLOCK | AcceptFlags::CLOEXEC)
|
rustix::net::acceptfrom_with(&self.fd, SocketFlags::NONBLOCK | SocketFlags::CLOEXEC)
|
||||||
.map(|(fd, addr)| {
|
.map(|(fd, addr)| {
|
||||||
(
|
(
|
||||||
TcpStream { fd },
|
TcpStream { fd },
|
||||||
|
@ -136,7 +133,7 @@ impl TcpListener {
|
||||||
family,
|
family,
|
||||||
SocketType::STREAM,
|
SocketType::STREAM,
|
||||||
SocketFlags::NONBLOCK | SocketFlags::CLOEXEC,
|
SocketFlags::NONBLOCK | SocketFlags::CLOEXEC,
|
||||||
Protocol::TCP,
|
Some(rustix::net::ipproto::TCP),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
rustix::net::sockopt::set_socket_reuseaddr(&sock, true)?;
|
rustix::net::sockopt::set_socket_reuseaddr(&sock, true)?;
|
||||||
|
@ -169,7 +166,7 @@ impl TcpStream {
|
||||||
family,
|
family,
|
||||||
SocketType::STREAM,
|
SocketType::STREAM,
|
||||||
SocketFlags::NONBLOCK | SocketFlags::CLOEXEC,
|
SocketFlags::NONBLOCK | SocketFlags::CLOEXEC,
|
||||||
Protocol::TCP,
|
Some(rustix::net::ipproto::TCP),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(TcpStreamBuilder {
|
Ok(TcpStreamBuilder {
|
||||||
|
|
Loading…
Reference in a new issue