Skip to content

Commit ca81f83

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 9b0555e commit ca81f83

32 files changed

+262
-262
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
@@ -18,13 +18,13 @@ arf-strings = { version = "0.6.7", optional = true }
1818
# Enable "unstable" for `spawn_blocking`.
1919
async-std = { version = "1.10.0", features = ["attributes", "unstable"] }
2020
cap-primitives = { path = "../cap-primitives", version = "^0.25.0" }
21-
io-lifetimes = { version = "0.7.0", default-features = false, features = ["async-std"] }
21+
io-lifetimes = { version = "1.0.0-rc1", default-features = false, features = ["async-std"] }
2222
ipnet = "2.3.0"
23-
io-extras = { version = "0.15.0", features = ["use_async_std"] }
23+
io-extras = { version = "0.16.0-rc1", features = ["use_async_std"] }
2424
camino = { version = "1.0.5", optional = true }
2525

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

2929
[features]
3030
default = []

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

+14-14
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ 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)]
20-
use io_lifetimes::{AsHandle, BorrowedHandle, FromHandle, IntoHandle, OwnedHandle};
20+
use io_lifetimes::{AsHandle, BorrowedHandle, OwnedHandle};
2121
use std::fmt;
2222
#[cfg(unix)]
2323
use {
@@ -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

@@ -887,10 +887,10 @@ impl FromRawHandle for Dir {
887887
}
888888

889889
#[cfg(windows)]
890-
impl FromHandle for Dir {
890+
impl From<OwnedHandle> for Dir {
891891
#[inline]
892-
fn from_handle(handle: OwnedHandle) -> Self {
893-
Self::from_std_file(fs::File::from_handle(handle))
892+
fn from(handle: OwnedHandle) -> Self {
893+
Self::from_std_file(fs::File::from(handle))
894894
}
895895
}
896896

@@ -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

@@ -959,10 +959,10 @@ impl IntoRawHandle for Dir {
959959
}
960960

961961
#[cfg(windows)]
962-
impl IntoHandle for Dir {
962+
impl From<Dir> for OwnedHandle {
963963
#[inline]
964-
fn into_handle(self) -> OwnedHandle {
965-
self.std_file.into_handle()
964+
fn from(dir: Dir) -> OwnedHandle {
965+
dir.std_file.into()
966966
}
967967
}
968968

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

+14-14
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ 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)]
15-
use io_lifetimes::{AsHandle, BorrowedHandle, FromHandle, IntoHandle, OwnedHandle};
15+
use io_lifetimes::{AsHandle, BorrowedHandle, OwnedHandle};
1616
use std::fmt;
1717
use std::path::Path;
1818
use std::pin::Pin;
@@ -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

@@ -213,10 +213,10 @@ impl FromRawHandle for File {
213213
}
214214

215215
#[cfg(windows)]
216-
impl FromHandle for File {
216+
impl From<OwnedHandle> for File {
217217
#[inline]
218-
fn from_handle(handle: OwnedHandle) -> Self {
219-
Self::from_std(fs::File::from_handle(handle))
218+
fn from(handle: OwnedHandle) -> Self {
219+
Self::from_std(fs::File::from(handle))
220220
}
221221
}
222222

@@ -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

@@ -285,10 +285,10 @@ impl IntoRawHandle for File {
285285
}
286286

287287
#[cfg(windows)]
288-
impl IntoHandle for File {
288+
impl From<File> for OwnedHandle {
289289
#[inline]
290-
fn into_handle(self) -> OwnedHandle {
291-
self.std.into_handle()
290+
fn from(file: File) -> OwnedHandle {
291+
file.std.into()
292292
}
293293
}
294294

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

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use cap_primitives::AmbientAuthority;
66
#[cfg(not(windows))]
77
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
88
#[cfg(windows)]
9-
use io_lifetimes::{AsHandle, BorrowedHandle, FromHandle, IntoHandle, OwnedHandle};
9+
use io_lifetimes::{AsHandle, BorrowedHandle, OwnedHandle};
1010
use std::fmt;
1111
#[cfg(unix)]
1212
use {
@@ -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

@@ -662,10 +662,10 @@ impl FromRawHandle for Dir {
662662
}
663663

664664
#[cfg(windows)]
665-
impl FromHandle for Dir {
665+
impl From<OwnedHandle> for Dir {
666666
#[inline]
667-
fn from_handle(handle: OwnedHandle) -> Self {
668-
Self::from_std_file(fs::File::from_handle(handle))
667+
fn from(handle: OwnedHandle) -> Self {
668+
Self::from_std_file(fs::File::from(handle))
669669
}
670670
}
671671

@@ -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

@@ -734,10 +734,10 @@ impl IntoRawHandle for Dir {
734734
}
735735

736736
#[cfg(windows)]
737-
impl IntoHandle for Dir {
737+
impl From<Dir> for OwnedHandle {
738738
#[inline]
739-
fn into_handle(self) -> OwnedHandle {
740-
self.cap_std.into_handle()
739+
fn from(dir: Dir) -> OwnedHandle {
740+
dir.cap_std.into()
741741
}
742742
}
743743

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

+13-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use cap_primitives::AmbientAuthority;
1212
#[cfg(not(windows))]
1313
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
1414
#[cfg(windows)]
15-
use io_lifetimes::{AsHandle, BorrowedHandle, FromHandle, IntoHandle, OwnedHandle};
15+
use io_lifetimes::{AsHandle, BorrowedHandle, OwnedHandle};
1616
use std::fmt;
1717
use std::pin::Pin;
1818
#[cfg(windows)]
@@ -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

@@ -176,10 +176,10 @@ impl FromRawHandle for File {
176176
}
177177

178178
#[cfg(windows)]
179-
impl FromHandle for File {
179+
impl From<OwnedHandle> for File {
180180
#[inline]
181-
fn from_handle(handle: OwnedHandle) -> Self {
182-
Self::from_std(fs::File::from_handle(handle))
181+
fn from(handle: OwnedHandle) -> Self {
182+
Self::from_std(fs::File::from(handle))
183183
}
184184
}
185185

@@ -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

@@ -248,10 +248,10 @@ impl IntoRawHandle for File {
248248
}
249249

250250
#[cfg(windows)]
251-
impl IntoHandle for File {
251+
impl From<File> for OwnedHandle {
252252
#[inline]
253-
fn into_handle(self) -> OwnedHandle {
254-
self.cap_std.into_handle()
253+
fn from(file: File) -> OwnedHandle {
254+
file.cap_std.into()
255255
}
256256
}
257257

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

+14-14
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ 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)]
8-
use io_lifetimes::{AsSocket, BorrowedSocket, FromSocket, IntoSocket, OwnedSocket};
8+
use io_lifetimes::{AsSocket, BorrowedSocket, OwnedSocket};
99
use std::fmt;
1010
#[cfg(windows)]
1111
use {
@@ -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

@@ -103,10 +103,10 @@ impl FromRawSocket for TcpListener {
103103
}
104104

105105
#[cfg(windows)]
106-
impl FromSocket for TcpListener {
106+
impl From<OwnedSocket> for TcpListener {
107107
#[inline]
108-
fn from_socket(socket: OwnedSocket) -> Self {
109-
Self::from_std(net::TcpListener::from_socket(socket))
108+
fn from(socket: OwnedSocket) -> Self {
109+
Self::from_std(net::TcpListener::from(socket))
110110
}
111111
}
112112

@@ -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

@@ -175,10 +175,10 @@ impl IntoRawSocket for TcpListener {
175175
}
176176

177177
#[cfg(windows)]
178-
impl IntoSocket for TcpListener {
178+
impl From<TcpListener> for OwnedSocket {
179179
#[inline]
180-
fn into_socket(self) -> OwnedSocket {
181-
self.std.into_socket()
180+
fn from(listener: TcpListener) -> OwnedSocket {
181+
listener.std.into()
182182
}
183183
}
184184

0 commit comments

Comments
 (0)