Skip to content

Commit 74729fa

Browse files
committed
Update to io-lifetimes 1.0.
This converts to the new traits, with `From` instead of `IntoFd` and `FromFd`. This currently depends on cap-async-std being disabled, since async-std doesn't yet have the io-safety trait impls yet.
1 parent dd13aff commit 74729fa

32 files changed

+171
-171
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ rand = "0.8.1"
2626
tempfile = "3.1.0"
2727
camino = "1.0.5"
2828
libc = "0.2.100"
29-
io-lifetimes = "0.7.0"
29+
io-lifetimes = "1.0.0-rc1"
3030

3131
[target.'cfg(not(windows))'.dev-dependencies]
32-
rustix = { version = "0.35.6", features = ["fs"] }
32+
rustix = { version = "0.36.0-rc1", features = ["fs"] }
3333

3434
[target.'cfg(windows)'.dev-dependencies]
3535
# nt_version uses internal Windows APIs, however we're only using it

cap-async-std/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ arf-strings = { version = "0.6.7", optional = true }
1717
# Enable "unstable" for `spawn_blocking`.
1818
async-std = { version = "1.10.0", features = ["attributes", "unstable"] }
1919
cap-primitives = { path = "../cap-primitives", version = "^0.25.0" }
20-
io-lifetimes = { version = "0.7.0", default-features = false, features = ["async-std"] }
20+
io-lifetimes = { version = "1.0.0-rc1", default-features = false, features = ["async-std"] }
2121
ipnet = "2.3.0"
22-
io-extras = { version = "0.15.0", features = ["use_async_std"] }
22+
io-extras = { version = "0.16.0-rc1", features = ["use_async_std"] }
2323
camino = { version = "1.0.5", optional = true }
2424

2525
[target.'cfg(not(windows))'.dependencies]
26-
rustix = { version = "0.35.6", features = ["fs"] }
26+
rustix = { version = "0.36.0-rc1", features = ["fs"] }
2727

2828
[features]
2929
default = []

cap-async-std/src/fs/dir.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use cap_primitives::fs::{
1414
};
1515
use cap_primitives::AmbientAuthority;
1616
#[cfg(not(windows))]
17-
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
17+
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
1818
use io_lifetimes::{AsFilelike, FromFilelike};
1919
#[cfg(windows)]
2020
use io_lifetimes::{AsHandle, BorrowedHandle, FromHandle, IntoHandle, OwnedHandle};
@@ -869,10 +869,10 @@ impl FromRawFd for Dir {
869869
}
870870

871871
#[cfg(not(windows))]
872-
impl FromFd for Dir {
872+
impl From<OwnedFd> for Dir {
873873
#[inline]
874-
fn from_fd(fd: OwnedFd) -> Self {
875-
Self::from_std_file(fs::File::from_fd(fd))
874+
fn from(fd: OwnedFd) -> Self {
875+
Self::from_std_file(fs::File::from(fd))
876876
}
877877
}
878878

@@ -943,10 +943,10 @@ impl IntoRawFd for Dir {
943943
}
944944

945945
#[cfg(not(windows))]
946-
impl IntoFd for Dir {
946+
impl From<Dir> for OwnedFd {
947947
#[inline]
948-
fn into_fd(self) -> OwnedFd {
949-
self.std_file.into_fd()
948+
fn from(dir: Dir) -> OwnedFd {
949+
dir.std_file.into()
950950
}
951951
}
952952

cap-async-std/src/fs/file.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use cap_primitives::fs::{is_file_read_write, open_ambient};
1010
use cap_primitives::AmbientAuthority;
1111
use io_lifetimes::AsFilelike;
1212
#[cfg(not(windows))]
13-
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
13+
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
1414
#[cfg(windows)]
1515
use io_lifetimes::{AsHandle, BorrowedHandle, FromHandle, IntoHandle, OwnedHandle};
1616
use std::fmt;
@@ -197,10 +197,10 @@ impl FromRawFd for File {
197197
}
198198

199199
#[cfg(not(windows))]
200-
impl FromFd for File {
200+
impl From<OwnedFd> for File {
201201
#[inline]
202-
fn from_fd(fd: OwnedFd) -> Self {
203-
Self::from_std(fs::File::from_fd(fd))
202+
fn from(fd: OwnedFd) -> Self {
203+
Self::from_std(fs::File::from(fd))
204204
}
205205
}
206206

@@ -269,10 +269,10 @@ impl IntoRawFd for File {
269269
}
270270

271271
#[cfg(not(windows))]
272-
impl IntoFd for File {
272+
impl From<File> for OwnedFd {
273273
#[inline]
274-
fn into_fd(self) -> OwnedFd {
275-
self.std.into_fd()
274+
fn from(file: File) -> OwnedFd {
275+
file.std.into()
276276
}
277277
}
278278

cap-async-std/src/fs_utf8/dir.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -644,10 +644,10 @@ impl FromRawFd for Dir {
644644
}
645645

646646
#[cfg(not(windows))]
647-
impl FromFd for Dir {
647+
impl From<OwnedFd> for Dir {
648648
#[inline]
649-
fn from_fd(fd: OwnedFd) -> Self {
650-
Self::from_std_file(fs::File::from_fd(fd))
649+
fn from(fd: OwnedFd) -> Self {
650+
Self::from_std_file(fs::File::from(fd))
651651
}
652652
}
653653

@@ -718,10 +718,10 @@ impl IntoRawFd for Dir {
718718
}
719719

720720
#[cfg(not(windows))]
721-
impl IntoFd for Dir {
721+
impl From<Dir> for OwnedFd {
722722
#[inline]
723-
fn into_fd(self) -> OwnedFd {
724-
self.cap_std.into_fd()
723+
fn from(dir: Dir) -> OwnedFd {
724+
dir.cap_std.into()
725725
}
726726
}
727727

cap-async-std/src/fs_utf8/file.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ impl FromRawFd for File {
160160
}
161161

162162
#[cfg(not(windows))]
163-
impl FromFd for File {
163+
impl From<OwnedFd> for File {
164164
#[inline]
165-
fn from_fd(fd: OwnedFd) -> Self {
166-
Self::from_std(fs::File::from_fd(fd))
165+
fn from(fd: OwnedFd) -> Self {
166+
Self::from_std(fs::File::from(fd))
167167
}
168168
}
169169

@@ -232,10 +232,10 @@ impl IntoRawFd for File {
232232
}
233233

234234
#[cfg(not(windows))]
235-
impl IntoFd for File {
235+
impl From<File> for OwnedFd {
236236
#[inline]
237-
fn into_fd(self) -> OwnedFd {
238-
self.cap_std.into_fd()
237+
fn from(file: File) -> OwnedFd {
238+
file.cap_std.into()
239239
}
240240
}
241241

cap-async-std/src/net/tcp_listener.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::net::{Incoming, SocketAddr, TcpStream};
33
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
44
use async_std::{io, net};
55
#[cfg(not(windows))]
6-
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
6+
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
77
#[cfg(windows)]
88
use io_lifetimes::{AsSocket, BorrowedSocket, FromSocket, IntoSocket, OwnedSocket};
99
use std::fmt;
@@ -87,10 +87,10 @@ impl FromRawFd for TcpListener {
8787
}
8888

8989
#[cfg(not(windows))]
90-
impl FromFd for TcpListener {
90+
impl From<OwnedFd> for TcpListener {
9191
#[inline]
92-
fn from_fd(fd: OwnedFd) -> Self {
93-
Self::from_std(net::TcpListener::from_fd(fd))
92+
fn from(fd: OwnedFd) -> Self {
93+
Self::from_std(net::TcpListener::from(fd))
9494
}
9595
}
9696

@@ -159,10 +159,10 @@ impl IntoRawFd for TcpListener {
159159
}
160160

161161
#[cfg(not(windows))]
162-
impl IntoFd for TcpListener {
162+
impl From<TcpListener> for OwnedFd {
163163
#[inline]
164-
fn into_fd(self) -> OwnedFd {
165-
self.std.into_fd()
164+
fn from(listener: TcpListener) -> OwnedFd {
165+
listener.std.into()
166166
}
167167
}
168168

cap-async-std/src/net/tcp_stream.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use async_std::net;
55
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
66
use async_std::task::{Context, Poll};
77
#[cfg(not(windows))]
8-
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
8+
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
99
#[cfg(windows)]
1010
use io_lifetimes::{AsSocket, BorrowedSocket, FromSocket, IntoSocket, OwnedSocket};
1111
use std::fmt;
@@ -131,10 +131,10 @@ impl FromRawFd for TcpStream {
131131
}
132132

133133
#[cfg(not(windows))]
134-
impl FromFd for TcpStream {
134+
impl From<OwnedFd> for TcpStream {
135135
#[inline]
136-
fn from_fd(fd: OwnedFd) -> Self {
137-
Self::from_std(net::TcpStream::from_fd(fd))
136+
fn from(fd: OwnedFd) -> Self {
137+
Self::from_std(net::TcpStream::from(fd))
138138
}
139139
}
140140

@@ -203,10 +203,10 @@ impl IntoRawFd for TcpStream {
203203
}
204204

205205
#[cfg(not(windows))]
206-
impl IntoFd for TcpStream {
206+
impl From<TcpStream> for OwnedFd {
207207
#[inline]
208-
fn into_fd(self) -> OwnedFd {
209-
self.std.into_fd()
208+
fn from(stream: TcpStream) -> OwnedFd {
209+
stream.std.into()
210210
}
211211
}
212212

cap-async-std/src/net/udp_socket.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
33
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
44
use async_std::{io, net};
55
#[cfg(not(windows))]
6-
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
6+
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
77
#[cfg(windows)]
88
use io_lifetimes::{AsSocket, BorrowedSocket, FromSocket, IntoSocket, OwnedSocket};
99
use std::fmt;
@@ -232,10 +232,10 @@ impl FromRawFd for UdpSocket {
232232
}
233233

234234
#[cfg(not(windows))]
235-
impl FromFd for UdpSocket {
235+
impl From<OwnedFd> for UdpSocket {
236236
#[inline]
237-
fn from_fd(fd: OwnedFd) -> Self {
238-
Self::from_std(net::UdpSocket::from_fd(fd))
237+
fn from(fd: OwnedFd) -> Self {
238+
Self::from_std(net::UdpSocket::from(fd))
239239
}
240240
}
241241

@@ -304,10 +304,10 @@ impl IntoRawFd for UdpSocket {
304304
}
305305

306306
#[cfg(not(windows))]
307-
impl IntoFd for UdpSocket {
307+
impl From<UdpSocket> for OwnedFd {
308308
#[inline]
309-
fn into_fd(self) -> OwnedFd {
310-
self.std.into_fd()
309+
fn from(socket: UdpSocket) -> OwnedFd {
310+
socket.std.into()
311311
}
312312
}
313313

cap-async-std/src/os/unix/net/unix_datagram.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::os::unix::net::SocketAddr;
33
use async_std::io;
44
use async_std::os::unix;
55
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
6-
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
6+
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
77
use std::fmt;
88

99
/// A Unix datagram socket.
@@ -148,10 +148,10 @@ impl FromRawFd for UnixDatagram {
148148
}
149149
}
150150

151-
impl FromFd for UnixDatagram {
151+
impl From<OwnedFd> for UnixDatagram {
152152
#[inline]
153-
fn from_fd(fd: OwnedFd) -> Self {
154-
Self::from_std(unix::net::UnixDatagram::from_fd(fd))
153+
fn from(fd: OwnedFd) -> Self {
154+
Self::from_std(unix::net::UnixDatagram::from(fd))
155155
}
156156
}
157157

@@ -176,10 +176,10 @@ impl IntoRawFd for UnixDatagram {
176176
}
177177
}
178178

179-
impl IntoFd for UnixDatagram {
179+
impl From<UnixDatagram> for OwnedFd {
180180
#[inline]
181-
fn into_fd(self) -> OwnedFd {
182-
self.std.into_fd()
181+
fn from(datagram: UnixDatagram) -> OwnedFd {
182+
datagram.std.into()
183183
}
184184
}
185185

cap-async-std/src/os/unix/net/unix_listener.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::os::unix::net::{Incoming, SocketAddr, UnixStream};
22
use async_std::io;
33
use async_std::os::unix;
44
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
5-
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
5+
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
66
use std::fmt;
77

88
/// A structure representing a Unix domain socket server.
@@ -82,10 +82,10 @@ impl FromRawFd for UnixListener {
8282
}
8383
}
8484

85-
impl FromFd for UnixListener {
85+
impl From<OwnedFd> for UnixListener {
8686
#[inline]
87-
fn from_fd(fd: OwnedFd) -> Self {
88-
Self::from_std(unix::net::UnixListener::from_fd(fd))
87+
fn from(fd: OwnedFd) -> Self {
88+
Self::from_std(unix::net::UnixListener::from(fd))
8989
}
9090
}
9191

@@ -110,10 +110,10 @@ impl IntoRawFd for UnixListener {
110110
}
111111
}
112112

113-
impl IntoFd for UnixListener {
113+
impl From<UnixListener> for OwnedFd {
114114
#[inline]
115-
fn into_fd(self) -> OwnedFd {
116-
self.std.into_fd()
115+
fn from(listener: UnixListener) -> OwnedFd {
116+
listener.std.into()
117117
}
118118
}
119119

cap-async-std/src/os/unix/net/unix_stream.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use async_std::io::{self, IoSlice, IoSliceMut, Read, Write};
44
use async_std::os::unix;
55
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
66
use async_std::task::{Context, Poll};
7-
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
7+
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
88
use std::fmt;
99
use std::pin::Pin;
1010

@@ -102,10 +102,10 @@ impl FromRawFd for UnixStream {
102102
}
103103
}
104104

105-
impl FromFd for UnixStream {
105+
impl From<OwnedFd> for UnixStream {
106106
#[inline]
107-
fn from_fd(fd: OwnedFd) -> Self {
108-
Self::from_std(unix::net::UnixStream::from_fd(fd))
107+
fn from(fd: OwnedFd) -> Self {
108+
Self::from_std(unix::net::UnixStream::from(fd))
109109
}
110110
}
111111

@@ -130,10 +130,10 @@ impl IntoRawFd for UnixStream {
130130
}
131131
}
132132

133-
impl IntoFd for UnixStream {
133+
impl From<UnixStream> for OwnedFd {
134134
#[inline]
135-
fn into_fd(self) -> OwnedFd {
136-
self.std.into_fd()
135+
fn from(stream: UnixStream) -> OwnedFd {
136+
stream.std.into()
137137
}
138138
}
139139

cap-directories/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cap-std = { path = "../cap-std", version = "^0.25.0" }
1717
directories-next = "2.0.0"
1818

1919
[target.'cfg(not(windows))'.dependencies]
20-
rustix = { version = "0.35.6" }
20+
rustix = { version = "0.36.0-rc1" }
2121

2222
[target.'cfg(windows)'.dependencies.windows-sys]
2323
version = "0.36.0"

cap-fs-ext/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ arf-strings = { version = "0.6.7", optional = true }
1717
#cap-async-std = { path = "../cap-async-std", optional = true, version = "^0.25.0" }
1818
cap-std = { path = "../cap-std", optional = true, version = "^0.25.0" }
1919
cap-primitives = { path = "../cap-primitives", version = "^0.25.0" }
20-
io-lifetimes = { version = "0.7.0", default-features = false }
20+
io-lifetimes = { version = "1.0.0-rc1", default-features = false }
2121
# Enable "unstable" for `spawn_blocking`.
2222
#async-std = { version = "1.10.0", features = ["attributes", "unstable"], optional = true }
2323
#async-trait = { version = "0.1.42", optional = true }

0 commit comments

Comments
 (0)