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 3855776
Show file tree
Hide file tree
Showing 32 changed files with 65 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
@@ -1,12 +1,11 @@
use std::{
any::Any,
fmt,
os::fd::{BorrowedFd, OwnedFd},
os::unix::{io::RawFd, net::UnixStream},
sync::Arc,
};

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 @@ -2,6 +2,7 @@

use std::{
fmt,
os::fd::{BorrowedFd, OwnedFd},
os::unix::{
io::{AsRawFd, RawFd},
net::UnixStream,
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
@@ -1,5 +1,6 @@
use std::{
ffi::CString,
os::fd::OwnedFd,
os::unix::{io::RawFd, net::UnixStream},
sync::Arc,
};
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,4 +1,5 @@
use std::{
os::fd::{BorrowedFd, OwnedFd},
os::unix::io::{AsRawFd, FromRawFd},
sync::{Arc, Mutex},
};
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
@@ -1,14 +1,13 @@
use std::{
ffi::CString,
os::fd::OwnedFd,
os::unix::{
io::{AsRawFd, RawFd},
net::UnixStream,
},
sync::{Arc, Mutex, Weak},
};

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,5 +1,6 @@
//! Server-side rust implementation of a Wayland protocol backend

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

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
@@ -1,10 +1,10 @@
//! Wayland socket manipulation

use std::io::{ErrorKind, IoSlice, IoSliceMut, Result as IoResult};
use std::os::fd::{AsFd, BorrowedFd, OwnedFd};
use std::os::unix::io::{AsRawFd, RawFd};
use std::os::unix::net::UnixStream;

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
@@ -1,11 +1,10 @@
//! Types and routines used to manipulate arguments from the wire format

use std::os::fd::{BorrowedFd, OwnedFd};
use std::os::unix::io::{FromRawFd, RawFd};
use std::ptr;
use std::{ffi::CStr, os::unix::prelude::AsRawFd};

use io_lifetimes::{BorrowedFd, OwnedFd};

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

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

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 @@ -3,6 +3,7 @@
use std::{
collections::HashSet,
ffi::CStr,
os::fd::{BorrowedFd, OwnedFd},
os::raw::{c_int, c_void},
os::unix::{
io::{FromRawFd, IntoRawFd, RawFd},
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 @@ -2,6 +2,7 @@

use std::{
ffi::{CStr, CString},
os::fd::{BorrowedFd, OwnedFd},
os::raw::{c_int, c_void},
os::unix::{
io::{FromRawFd, IntoRawFd, RawFd},
Expand All @@ -17,7 +18,6 @@ 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,9 +1,8 @@
#![allow(dead_code, non_snake_case)]

use std::os::fd::OwnedFd;
use std::sync::Arc;

use io_lifetimes::OwnedFd;

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

use crate::rs::{client as client_rs, server as server_rs};
Expand Down
2 changes: 1 addition & 1 deletion wayland-client/src/conn.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{
env, fmt,
io::ErrorKind,
os::fd::OwnedFd,
os::unix::net::UnixStream,
os::unix::prelude::{AsRawFd, FromRawFd},
path::PathBuf,
Expand All @@ -12,7 +13,6 @@ use std::{

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 @@ -2,13 +2,13 @@ use std::any::Any;
use std::collections::VecDeque;
use std::convert::Infallible;
use std::marker::PhantomData;
use std::os::fd::OwnedFd;
use std::sync::{atomic::Ordering, Arc, Condvar, Mutex};
use std::task;

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 @@ -55,6 +55,7 @@
use std::{
fmt,
ops::RangeInclusive,
os::fd::OwnedFd,
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex,
Expand All @@ -63,7 +64,6 @@ use std::{

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 @@ -169,12 +169,12 @@
use std::{
fmt,
hash::{Hash, Hasher},
os::fd::OwnedFd,
os::unix::io::RawFd,
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 @@ -49,6 +49,7 @@ use std::env;
use std::fs::File;
use std::io::{Error as IoError, Read, Result as IoResult, Seek, SeekFrom, Write};
use std::ops::{Deref, Index};
use std::os::fd::OwnedFd;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
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 3855776

Please sign in to comment.