Skip to content

Commit

Permalink
Update to io-lifetimes 1.0.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sunfishcode committed Aug 23, 2022
1 parent 2958354 commit d5314d4
Show file tree
Hide file tree
Showing 32 changed files with 171 additions and 171 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ rand = "0.8.1"
tempfile = "3.1.0"
camino = "1.0.5"
libc = "0.2.100"
io-lifetimes = "0.7.0"
io-lifetimes = "1.0.0-rc1"

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

[target.'cfg(windows)'.dev-dependencies]
# nt_version uses internal Windows APIs, however we're only using it
Expand Down
6 changes: 3 additions & 3 deletions cap-async-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ arf-strings = { version = "0.6.7", optional = true }
# Enable "unstable" for `spawn_blocking`.
async-std = { version = "1.10.0", features = ["attributes", "unstable"] }
cap-primitives = { path = "../cap-primitives", version = "^0.25.0" }
io-lifetimes = { version = "0.7.0", default-features = false, features = ["async-std"] }
io-lifetimes = { version = "1.0.0-rc1", default-features = false, features = ["async-std"] }
ipnet = "2.3.0"
io-extras = { version = "0.15.0", features = ["use_async_std"] }
io-extras = { version = "0.16.0-rc1", features = ["use_async_std"] }
camino = { version = "1.0.5", optional = true }

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

[features]
default = []
Expand Down
14 changes: 7 additions & 7 deletions cap-async-std/src/fs/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use cap_primitives::fs::{
};
use cap_primitives::AmbientAuthority;
#[cfg(not(windows))]
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
use io_lifetimes::{AsFilelike, FromFilelike};
#[cfg(windows)]
use io_lifetimes::{AsHandle, BorrowedHandle, FromHandle, IntoHandle, OwnedHandle};
Expand Down Expand Up @@ -869,10 +869,10 @@ impl FromRawFd for Dir {
}

#[cfg(not(windows))]
impl FromFd for Dir {
impl From<OwnedFd> for Dir {
#[inline]
fn from_fd(fd: OwnedFd) -> Self {
Self::from_std_file(fs::File::from_fd(fd))
fn from(fd: OwnedFd) -> Self {
Self::from_std_file(fs::File::from(fd))
}
}

Expand Down Expand Up @@ -943,10 +943,10 @@ impl IntoRawFd for Dir {
}

#[cfg(not(windows))]
impl IntoFd for Dir {
impl From<Dir> for OwnedFd {
#[inline]
fn into_fd(self) -> OwnedFd {
self.std_file.into_fd()
fn from(dir: Dir) -> OwnedFd {
dir.std_file.into()
}
}

Expand Down
14 changes: 7 additions & 7 deletions cap-async-std/src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use cap_primitives::fs::{is_file_read_write, open_ambient};
use cap_primitives::AmbientAuthority;
use io_lifetimes::AsFilelike;
#[cfg(not(windows))]
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
#[cfg(windows)]
use io_lifetimes::{AsHandle, BorrowedHandle, FromHandle, IntoHandle, OwnedHandle};
use std::fmt;
Expand Down Expand Up @@ -197,10 +197,10 @@ impl FromRawFd for File {
}

#[cfg(not(windows))]
impl FromFd for File {
impl From<OwnedFd> for File {
#[inline]
fn from_fd(fd: OwnedFd) -> Self {
Self::from_std(fs::File::from_fd(fd))
fn from(fd: OwnedFd) -> Self {
Self::from_std(fs::File::from(fd))
}
}

Expand Down Expand Up @@ -269,10 +269,10 @@ impl IntoRawFd for File {
}

#[cfg(not(windows))]
impl IntoFd for File {
impl From<File> for OwnedFd {
#[inline]
fn into_fd(self) -> OwnedFd {
self.std.into_fd()
fn from(file: File) -> OwnedFd {
file.std.into()
}
}

Expand Down
12 changes: 6 additions & 6 deletions cap-async-std/src/fs_utf8/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,10 @@ impl FromRawFd for Dir {
}

#[cfg(not(windows))]
impl FromFd for Dir {
impl From<OwnedFd> for Dir {
#[inline]
fn from_fd(fd: OwnedFd) -> Self {
Self::from_std_file(fs::File::from_fd(fd))
fn from(fd: OwnedFd) -> Self {
Self::from_std_file(fs::File::from(fd))
}
}

Expand Down Expand Up @@ -718,10 +718,10 @@ impl IntoRawFd for Dir {
}

#[cfg(not(windows))]
impl IntoFd for Dir {
impl From<Dir> for OwnedFd {
#[inline]
fn into_fd(self) -> OwnedFd {
self.cap_std.into_fd()
fn from(dir: Dir) -> OwnedFd {
dir.cap_std.into()
}
}

Expand Down
12 changes: 6 additions & 6 deletions cap-async-std/src/fs_utf8/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ impl FromRawFd for File {
}

#[cfg(not(windows))]
impl FromFd for File {
impl From<OwnedFd> for File {
#[inline]
fn from_fd(fd: OwnedFd) -> Self {
Self::from_std(fs::File::from_fd(fd))
fn from(fd: OwnedFd) -> Self {
Self::from_std(fs::File::from(fd))
}
}

Expand Down Expand Up @@ -232,10 +232,10 @@ impl IntoRawFd for File {
}

#[cfg(not(windows))]
impl IntoFd for File {
impl From<File> for OwnedFd {
#[inline]
fn into_fd(self) -> OwnedFd {
self.cap_std.into_fd()
fn from(file: File) -> OwnedFd {
file.cap_std.into()
}
}

Expand Down
14 changes: 7 additions & 7 deletions cap-async-std/src/net/tcp_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::net::{Incoming, SocketAddr, TcpStream};
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use async_std::{io, net};
#[cfg(not(windows))]
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
#[cfg(windows)]
use io_lifetimes::{AsSocket, BorrowedSocket, FromSocket, IntoSocket, OwnedSocket};
use std::fmt;
Expand Down Expand Up @@ -87,10 +87,10 @@ impl FromRawFd for TcpListener {
}

#[cfg(not(windows))]
impl FromFd for TcpListener {
impl From<OwnedFd> for TcpListener {
#[inline]
fn from_fd(fd: OwnedFd) -> Self {
Self::from_std(net::TcpListener::from_fd(fd))
fn from(fd: OwnedFd) -> Self {
Self::from_std(net::TcpListener::from(fd))
}
}

Expand Down Expand Up @@ -159,10 +159,10 @@ impl IntoRawFd for TcpListener {
}

#[cfg(not(windows))]
impl IntoFd for TcpListener {
impl From<TcpListener> for OwnedFd {
#[inline]
fn into_fd(self) -> OwnedFd {
self.std.into_fd()
fn from(listener: TcpListener) -> OwnedFd {
listener.std.into()
}
}

Expand Down
14 changes: 7 additions & 7 deletions cap-async-std/src/net/tcp_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use async_std::net;
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use async_std::task::{Context, Poll};
#[cfg(not(windows))]
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
#[cfg(windows)]
use io_lifetimes::{AsSocket, BorrowedSocket, FromSocket, IntoSocket, OwnedSocket};
use std::fmt;
Expand Down Expand Up @@ -131,10 +131,10 @@ impl FromRawFd for TcpStream {
}

#[cfg(not(windows))]
impl FromFd for TcpStream {
impl From<OwnedFd> for TcpStream {
#[inline]
fn from_fd(fd: OwnedFd) -> Self {
Self::from_std(net::TcpStream::from_fd(fd))
fn from(fd: OwnedFd) -> Self {
Self::from_std(net::TcpStream::from(fd))
}
}

Expand Down Expand Up @@ -203,10 +203,10 @@ impl IntoRawFd for TcpStream {
}

#[cfg(not(windows))]
impl IntoFd for TcpStream {
impl From<TcpStream> for OwnedFd {
#[inline]
fn into_fd(self) -> OwnedFd {
self.std.into_fd()
fn from(stream: TcpStream) -> OwnedFd {
stream.std.into()
}
}

Expand Down
14 changes: 7 additions & 7 deletions cap-async-std/src/net/udp_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use async_std::{io, net};
#[cfg(not(windows))]
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
#[cfg(windows)]
use io_lifetimes::{AsSocket, BorrowedSocket, FromSocket, IntoSocket, OwnedSocket};
use std::fmt;
Expand Down Expand Up @@ -232,10 +232,10 @@ impl FromRawFd for UdpSocket {
}

#[cfg(not(windows))]
impl FromFd for UdpSocket {
impl From<OwnedFd> for UdpSocket {
#[inline]
fn from_fd(fd: OwnedFd) -> Self {
Self::from_std(net::UdpSocket::from_fd(fd))
fn from(fd: OwnedFd) -> Self {
Self::from_std(net::UdpSocket::from(fd))
}
}

Expand Down Expand Up @@ -304,10 +304,10 @@ impl IntoRawFd for UdpSocket {
}

#[cfg(not(windows))]
impl IntoFd for UdpSocket {
impl From<UdpSocket> for OwnedFd {
#[inline]
fn into_fd(self) -> OwnedFd {
self.std.into_fd()
fn from(socket: UdpSocket) -> OwnedFd {
socket.std.into()
}
}

Expand Down
14 changes: 7 additions & 7 deletions cap-async-std/src/os/unix/net/unix_datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::os::unix::net::SocketAddr;
use async_std::io;
use async_std::os::unix;
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
use std::fmt;

/// A Unix datagram socket.
Expand Down Expand Up @@ -148,10 +148,10 @@ impl FromRawFd for UnixDatagram {
}
}

impl FromFd for UnixDatagram {
impl From<OwnedFd> for UnixDatagram {
#[inline]
fn from_fd(fd: OwnedFd) -> Self {
Self::from_std(unix::net::UnixDatagram::from_fd(fd))
fn from(fd: OwnedFd) -> Self {
Self::from_std(unix::net::UnixDatagram::from(fd))
}
}

Expand All @@ -176,10 +176,10 @@ impl IntoRawFd for UnixDatagram {
}
}

impl IntoFd for UnixDatagram {
impl From<UnixDatagram> for OwnedFd {
#[inline]
fn into_fd(self) -> OwnedFd {
self.std.into_fd()
fn from(datagram: UnixDatagram) -> OwnedFd {
datagram.std.into()
}
}

Expand Down
14 changes: 7 additions & 7 deletions cap-async-std/src/os/unix/net/unix_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::os::unix::net::{Incoming, SocketAddr, UnixStream};
use async_std::io;
use async_std::os::unix;
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
use std::fmt;

/// A structure representing a Unix domain socket server.
Expand Down Expand Up @@ -82,10 +82,10 @@ impl FromRawFd for UnixListener {
}
}

impl FromFd for UnixListener {
impl From<OwnedFd> for UnixListener {
#[inline]
fn from_fd(fd: OwnedFd) -> Self {
Self::from_std(unix::net::UnixListener::from_fd(fd))
fn from(fd: OwnedFd) -> Self {
Self::from_std(unix::net::UnixListener::from(fd))
}
}

Expand All @@ -110,10 +110,10 @@ impl IntoRawFd for UnixListener {
}
}

impl IntoFd for UnixListener {
impl From<UnixListener> for OwnedFd {
#[inline]
fn into_fd(self) -> OwnedFd {
self.std.into_fd()
fn from(listener: UnixListener) -> OwnedFd {
listener.std.into()
}
}

Expand Down
14 changes: 7 additions & 7 deletions cap-async-std/src/os/unix/net/unix_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use async_std::io::{self, IoSlice, IoSliceMut, Read, Write};
use async_std::os::unix;
use async_std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use async_std::task::{Context, Poll};
use io_lifetimes::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
use std::fmt;
use std::pin::Pin;

Expand Down Expand Up @@ -102,10 +102,10 @@ impl FromRawFd for UnixStream {
}
}

impl FromFd for UnixStream {
impl From<OwnedFd> for UnixStream {
#[inline]
fn from_fd(fd: OwnedFd) -> Self {
Self::from_std(unix::net::UnixStream::from_fd(fd))
fn from(fd: OwnedFd) -> Self {
Self::from_std(unix::net::UnixStream::from(fd))
}
}

Expand All @@ -130,10 +130,10 @@ impl IntoRawFd for UnixStream {
}
}

impl IntoFd for UnixStream {
impl From<UnixStream> for OwnedFd {
#[inline]
fn into_fd(self) -> OwnedFd {
self.std.into_fd()
fn from(stream: UnixStream) -> OwnedFd {
stream.std.into()
}
}

Expand Down
2 changes: 1 addition & 1 deletion cap-directories/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cap-std = { path = "../cap-std", version = "^0.25.0" }
directories-next = "2.0.0"

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

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.36.0"
Expand Down
2 changes: 1 addition & 1 deletion cap-fs-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ arf-strings = { version = "0.6.7", optional = true }
#cap-async-std = { path = "../cap-async-std", optional = true, version = "^0.25.0" }
cap-std = { path = "../cap-std", optional = true, version = "^0.25.0" }
cap-primitives = { path = "../cap-primitives", version = "^0.25.0" }
io-lifetimes = { version = "0.7.0", default-features = false }
io-lifetimes = { version = "1.0.0-rc1", default-features = false }
# Enable "unstable" for `spawn_blocking`.
#async-std = { version = "1.10.0", features = ["attributes", "unstable"], optional = true }
#async-trait = { version = "0.1.42", optional = true }
Expand Down
Loading

0 comments on commit d5314d4

Please sign in to comment.