Skip to content

Commit

Permalink
Replace io-lifetimes with std::os::fd
Browse files Browse the repository at this point in the history
Since Rust 1.63, most of the features of io-lifetimes have been merged
into std, including the only three we are using: OwnedFd, BorrowedFd and
the AsFd trait.

This bumps our MSRV, but this is the MSRV of the newest io-lifetimes
anyway.

I kept reexporting io_lifetimes as it was part of the public interface,
but since it isn’t used any more it would be nice to remove it before
the next minor version bump.  I can prepare a commit for that.
  • Loading branch information
linkmauve committed Jul 22, 2023
1 parent 5774a01 commit 50a1ec4
Show file tree
Hide file tree
Showing 32 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The documentation for the releases can be found on [docs.rs](https://docs.rs/):

## Requirements

Requires at least rust 1.59.0 to be used, and version 1.15 of the wayland system libraries if using the
Requires at least rust 1.63.0 to be used, and version 1.15 of the wayland system libraries if using the
system backend.

## Chat and support
Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ wayland-sys = { version = "0.31.0", path = "../wayland-sys", features = [] }
log = { version = "0.4", optional = true }
scoped-tls = "1.0"
downcast-rs = "1.2"
io-lifetimes = "1.0.0"
io-lifetimes = "2"
raw-window-handle = { version = "0.5.0", optional = true }

[dependencies.smallvec]
Expand Down
3 changes: 1 addition & 2 deletions wayland-backend/src/client_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use std::{
fmt,
os::unix::{io::RawFd, net::UnixStream},
sync::Arc,
os::fd::{OwnedFd, BorrowedFd},
};

use io_lifetimes::{BorrowedFd, OwnedFd};

use crate::protocol::{Interface, Message, ObjectInfo};

use super::client_impl;
Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/src/rs/client_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{
net::UnixStream,
},
sync::{Arc, Condvar, Mutex, MutexGuard, Weak},
os::fd::{OwnedFd, BorrowedFd},
};

use crate::{
Expand All @@ -17,7 +18,6 @@ use crate::{
INLINE_ARGS,
},
};
use io_lifetimes::{BorrowedFd, OwnedFd};
use smallvec::SmallVec;

use super::{
Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/src/rs/server_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{
ffi::CString,
os::unix::{io::RawFd, net::UnixStream},
sync::Arc,
os::fd::OwnedFd,
};

use crate::{
Expand All @@ -15,7 +16,6 @@ use crate::{
types::server::{DisconnectReason, InvalidId},
};

use io_lifetimes::OwnedFd;
use smallvec::SmallVec;

use crate::rs::{
Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/src/rs/server_impl/common_poll.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{
os::unix::io::{AsRawFd, FromRawFd},
sync::{Arc, Mutex},
os::fd::{OwnedFd, BorrowedFd},
};

use super::{
Expand All @@ -14,7 +15,6 @@ use crate::{
types::server::InitError,
};

use io_lifetimes::{BorrowedFd, OwnedFd};
#[cfg(any(target_os = "linux", target_os = "android"))]
use nix::sys::epoll::*;

Expand Down
3 changes: 1 addition & 2 deletions wayland-backend/src/rs/server_impl/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ use std::{
net::UnixStream,
},
sync::{Arc, Mutex, Weak},
os::fd::OwnedFd,
};

use io_lifetimes::OwnedFd;

use crate::{
protocol::{same_interface, Interface, Message, ObjectInfo, ANONYMOUS_INTERFACE},
types::server::{DisconnectReason, GlobalInfo, InvalidId},
Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/src/rs/server_impl/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Server-side rust implementation of a Wayland protocol backend

use std::{fmt, sync::Arc};
use std::os::fd::OwnedFd;

use crate::protocol::{same_interface, Interface, Message};

Expand All @@ -12,7 +13,6 @@ mod registry;
pub use crate::types::server::{Credentials, DisconnectReason, GlobalInfo, InitError, InvalidId};
pub use common_poll::InnerBackend;
pub use handle::{InnerHandle, WeakInnerHandle};
use io_lifetimes::OwnedFd;

use super::server::*;

Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/src/rs/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use std::io::{ErrorKind, IoSlice, IoSliceMut, Result as IoResult};
use std::os::unix::io::{AsRawFd, RawFd};
use std::os::unix::net::UnixStream;
use std::os::fd::{OwnedFd, BorrowedFd, AsFd};

use io_lifetimes::{AsFd, BorrowedFd, OwnedFd};
use nix::sys::socket;

use crate::protocol::{ArgumentType, Message};
Expand Down
3 changes: 1 addition & 2 deletions wayland-backend/src/rs/wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
use std::os::unix::io::{FromRawFd, RawFd};
use std::ptr;
use std::{ffi::CStr, os::unix::prelude::AsRawFd};

use io_lifetimes::{BorrowedFd, OwnedFd};
use std::os::fd::{OwnedFd, BorrowedFd};

use crate::protocol::{Argument, ArgumentType, Message};

Expand Down
3 changes: 1 addition & 2 deletions wayland-backend/src/server_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use std::{
fmt,
os::unix::{io::RawFd, net::UnixStream},
sync::Arc,
os::fd::{OwnedFd, BorrowedFd},
};

use io_lifetimes::{BorrowedFd, OwnedFd};

use crate::protocol::{Interface, Message, ObjectInfo};
pub use crate::types::server::{Credentials, DisconnectReason, GlobalInfo, InitError, InvalidId};

Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/src/sys/client_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{
atomic::{AtomicBool, Ordering},
Arc, Mutex, MutexGuard, Weak,
},
os::fd::{OwnedFd, BorrowedFd},
};

use crate::{
Expand All @@ -21,7 +22,6 @@ use crate::{
ObjectInfo, ProtocolError, ANONYMOUS_INTERFACE,
},
};
use io_lifetimes::{BorrowedFd, OwnedFd};
use scoped_tls::scoped_thread_local;
use smallvec::SmallVec;

Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/src/sys/server_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ use std::{
atomic::{AtomicBool, Ordering},
Arc, Mutex, Weak,
},
os::fd::{OwnedFd, BorrowedFd},
};

use crate::protocol::{
check_for_signature, same_interface, AllowNull, Argument, ArgumentType, Interface, Message,
ObjectInfo, ANONYMOUS_INTERFACE,
};
use io_lifetimes::{BorrowedFd, OwnedFd};
use scoped_tls::scoped_thread_local;
use smallvec::SmallVec;

Expand Down
3 changes: 1 addition & 2 deletions wayland-backend/src/test/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#![allow(dead_code, non_snake_case)]

use std::sync::Arc;

use io_lifetimes::OwnedFd;
use std::os::fd::OwnedFd;

use crate::protocol::{Argument, Message};

Expand Down
2 changes: 1 addition & 1 deletion wayland-client/src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use std::{
atomic::{AtomicBool, Ordering},
Arc,
},
os::fd::OwnedFd,
};

use wayland_backend::{
client::{Backend, InvalidId, ObjectData, ObjectId, ReadEventsGuard, WaylandError},
io_lifetimes::OwnedFd,
protocol::{ObjectInfo, ProtocolError},
};

Expand Down
2 changes: 1 addition & 1 deletion wayland-client/src/event_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use std::convert::Infallible;
use std::marker::PhantomData;
use std::sync::{atomic::Ordering, Arc, Condvar, Mutex};
use std::task;
use std::os::fd::OwnedFd;

use nix::Error;
use wayland_backend::{
client::{Backend, ObjectData, ObjectId, ReadEventsGuard, WaylandError},
io_lifetimes::OwnedFd,
protocol::{Argument, Message},
};

Expand Down
2 changes: 1 addition & 1 deletion wayland-client/src/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ use std::{
atomic::{AtomicBool, Ordering},
Arc, Mutex,
},
os::fd::OwnedFd,
};

use wayland_backend::{
client::{Backend, InvalidId, ObjectData, ObjectId, WaylandError},
io_lifetimes::OwnedFd,
protocol::Message,
};

Expand Down
2 changes: 1 addition & 1 deletion wayland-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ use std::{
fmt,
hash::{Hash, Hasher},
os::unix::io::RawFd,
os::fd::OwnedFd,
sync::Arc,
};
use wayland_backend::{
client::{InvalidId, ObjectData, ObjectId, WaylandError, WeakBackend},
io_lifetimes::OwnedFd,
protocol::{Interface, Message},
};

Expand Down
2 changes: 1 addition & 1 deletion wayland-cursor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ use std::ops::{Deref, Index};
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use std::os::fd::OwnedFd;

use nix::errno::Errno;
use nix::fcntl;
Expand All @@ -60,7 +61,6 @@ use nix::unistd;
#[cfg(any(target_os = "linux", target_os = "android"))]
use {nix::sys::memfd, std::ffi::CStr};

use wayland_client::backend::io_lifetimes::OwnedFd;
use wayland_client::backend::{InvalidId, ObjectData, WeakBackend};
use wayland_client::protocol::wl_buffer::WlBuffer;
use wayland_client::protocol::wl_shm::{self, Format, WlShm};
Expand Down
5 changes: 3 additions & 2 deletions wayland-scanner/src/client_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ fn generate_objects_for(interface: &Interface) -> TokenStream {
#mod_doc
pub mod #mod_name {
use std::sync::Arc;
use std::os::fd::OwnedFd;

use super::wayland_client::{
backend::{
Backend, WeakBackend, smallvec, ObjectData, ObjectId, InvalidId, io_lifetimes,
Backend, WeakBackend, smallvec, ObjectData, ObjectId, InvalidId,
protocol::{WEnum, Argument, Message, Interface, same_interface}
},
QueueProxyData, Proxy, Connection, Dispatch, QueueHandle, DispatchError, Weak,
Expand Down Expand Up @@ -163,7 +164,7 @@ fn generate_objects_for(interface: &Interface) -> TokenStream {
#iface_name { id: ObjectId::null(), data: None, version: 0, backend }
}

fn parse_event(conn: &Connection, msg: Message<ObjectId, io_lifetimes::OwnedFd>) -> Result<(Self, Self::Event), DispatchError> {
fn parse_event(conn: &Connection, msg: Message<ObjectId, OwnedFd>) -> Result<(Self, Self::Event), DispatchError> {
#parse_body
}

Expand Down
2 changes: 1 addition & 1 deletion wayland-scanner/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub(crate) fn gen_message_enum(
Type::Array => quote! { Vec<u8> },
Type::Fd => {
if receiver {
quote! { io_lifetimes::OwnedFd }
quote! { OwnedFd }
} else {
quote! { std::os::unix::io::RawFd }
}
Expand Down
5 changes: 3 additions & 2 deletions wayland-scanner/src/server_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ fn generate_objects_for(interface: &Interface) -> TokenStream {
#mod_doc
pub mod #mod_name {
use std::sync::Arc;
use std::os::fd::OwnedFd;

use super::wayland_server::{
backend::{
smallvec, ObjectData, ObjectId, InvalidId, io_lifetimes, WeakHandle,
smallvec, ObjectData, ObjectId, InvalidId, WeakHandle,
protocol::{WEnum, Argument, Message, Interface, same_interface}
},
Resource, Dispatch, DisplayHandle, DispatchError, ResourceData, New, Weak,
Expand Down Expand Up @@ -155,7 +156,7 @@ fn generate_objects_for(interface: &Interface) -> TokenStream {
handle.send_event(self, evt)
}

fn parse_request(conn: &DisplayHandle, msg: Message<ObjectId, io_lifetimes::OwnedFd>) -> Result<(Self, Self::Request), DispatchError> {
fn parse_request(conn: &DisplayHandle, msg: Message<ObjectId, OwnedFd>) -> Result<(Self, Self::Request), DispatchError> {
#parse_body
}

Expand Down
Loading

0 comments on commit 50a1ec4

Please sign in to comment.