Skip to content

Commit 28109d2

Browse files
committed
Upgrade to rustix 1.0
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
1 parent bb55023 commit 28109d2

21 files changed

+116
-88
lines changed

Cargo.lock

+42-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ rand_xoshiro = "0.7.0"
2727
regex = "1.11.1"
2828
ringboard-sdk = { package = "clipboard-history-client-sdk", version = "0", path = "../client-sdk", features = ["error-stack", "deduplication", "search", "config"] }
2929
rustc-hash = "2.1.1"
30-
rustix = { version = "0.38.44", features = ["stdio", "event"] }
30+
rustix = { version = "1.0.0-prerelease.1", features = ["stdio", "event"] }
3131
serde = { version = "1.0.218", features = ["derive"] }
3232
serde_json = "1.0.139"
3333
thiserror = "2.0.11"

client-sdk/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ memchr = { version = "2.7.4", optional = true }
1818
regex = { version = "1.11.1", optional = true }
1919
ringboard-core = { package = "clipboard-history-core", version = "0", path = "../core" }
2020
rustc-hash = { version = "2.1.1", optional = true }
21-
rustix = { version = "0.38.44", features = ["net", "fs", "thread"] }
21+
rustix = { version = "1.0.0-prerelease.1", features = ["net", "fs", "thread"] }
2222
serde = { version = "1.0.218", features = ["derive"], optional = true }
2323
smallvec = { version = "2.0.0-alpha.10", optional = true }
2424
thiserror = "2.0.11"

client-sdk/api.golden

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub unsafe fn clipboard_history_client_sdk::api::MoveToFrontRequest::deref_mut<'
107107
pub unsafe fn clipboard_history_client_sdk::api::MoveToFrontRequest::drop(ptr: usize)
108108
pub unsafe fn clipboard_history_client_sdk::api::MoveToFrontRequest::init(init: <T as crossbeam_epoch::atomic::Pointable>::Init) -> usize
109109
impl<T> either::into_either::IntoEither for clipboard_history_client_sdk::api::MoveToFrontRequest
110-
#[repr(C)] pub struct clipboard_history_client_sdk::api::PasteCommand
110+
pub struct clipboard_history_client_sdk::api::PasteCommand
111111
pub clipboard_history_client_sdk::api::PasteCommand::id: u64
112112
pub clipboard_history_client_sdk::api::PasteCommand::mime: clipboard_history_core::protocol::MimeType
113113
pub clipboard_history_client_sdk::api::PasteCommand::trigger_paste: bool

client-sdk/src/api.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{
33
fs::File,
44
io,
55
io::{IoSlice, IoSliceMut, Seek, SeekFrom},
6-
mem::ManuallyDrop,
6+
mem::{ManuallyDrop, MaybeUninit},
77
os::fd::{AsFd, AsRawFd, FromRawFd, OwnedFd},
88
};
99

@@ -17,9 +17,9 @@ use ringboard_core::{
1717
use rustix::{
1818
fs::{AtFlags, CWD, FileType, Mode, OFlags, StatxFlags, statx},
1919
net::{
20-
AddressFamily, RecvAncillaryBuffer, RecvFlags, SendAncillaryBuffer, SendAncillaryMessage,
21-
SendFlags, SocketAddrUnix, SocketFlags, SocketType, connect_unix, recvmsg, sendmsg,
22-
socket_with,
20+
AddressFamily, RecvAncillaryBuffer, RecvFlags, ReturnFlags, SendAncillaryBuffer,
21+
SendAncillaryMessage, SendFlags, SocketAddrUnix, SocketFlags, SocketType, connect, recvmsg,
22+
sendmsg, socket_with,
2323
},
2424
};
2525

@@ -58,7 +58,7 @@ pub fn connect_to_server_with(
5858
) -> Result<OwnedFd, ClientError> {
5959
let socket = socket_with(AddressFamily::UNIX, SocketType::SEQPACKET, flags, None)
6060
.map_io_err(|| format!("Failed to create socket: {addr:?}"))?;
61-
connect_unix(&socket, addr).map_io_err(|| format!("Failed to connect to server: {addr:?}"))?;
61+
connect(&socket, addr).map_io_err(|| format!("Failed to connect to server: {addr:?}"))?;
6262

6363
{
6464
sendmsg(
@@ -95,7 +95,7 @@ pub fn connect_to_paste_server(addr: &SocketAddrUnix) -> Result<OwnedFd, ClientE
9595
None,
9696
)
9797
.map_io_err(|| format!("Failed to create socket: {addr:?}"))?;
98-
connect_unix(&sock, addr).map_io_err(|| format!("Failed to connect to server: {addr:?}"))?;
98+
connect(&sock, addr).map_io_err(|| format!("Failed to connect to server: {addr:?}"))?;
9999
Ok(sock)
100100
}
101101

@@ -121,7 +121,7 @@ pub fn send_paste_buffer(
121121
let file = entry.to_file(reader)?;
122122
let mime = file.mime_type()?;
123123

124-
let mut space = [0; rustix::cmsg_space!(ScmRights(1))];
124+
let mut space = [MaybeUninit::uninit(); rustix::cmsg_space!(ScmRights(1))];
125125
let mut ancillary = SendAncillaryBuffer::new(&mut space);
126126
let fds = [file.as_fd()];
127127
{
@@ -336,7 +336,7 @@ fn request_with_fd(
336336
fd: impl AsFd,
337337
flags: SendFlags,
338338
) -> Result<(), ClientError> {
339-
let mut space = [0; rustix::cmsg_space!(ScmRights(1))];
339+
let mut space = [MaybeUninit::uninit(); rustix::cmsg_space!(ScmRights(1))];
340340
let mut buf = SendAncillaryBuffer::new(&mut space);
341341
let fds = [fd.as_fd()];
342342
{
@@ -390,7 +390,7 @@ unsafe fn response<T: Copy + 'static, const N: usize>(
390390
context: format!("Bad {}.", type_name()).into(),
391391
});
392392
}
393-
debug_assert!(!result.flags.contains(RecvFlags::TRUNC));
393+
debug_assert!(!result.flags.contains(ReturnFlags::TRUNC));
394394

395395
if TypeId::of::<T>() == TypeId::of::<VersionResponse>() {
396396
Ok(Response {

client-sdk/src/ring_reader.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,15 @@ pub fn xattr_mime_type<Fd: AsFd, MetadataFd: AsFd, MetadataPath: Arg + Copy + De
303303
.map_io_err(|| format!("Failed to read metadata file: {file_name:?}"))?;
304304
} else {
305305
let mut mime_type = mime_type.unfilled();
306-
mime_type.ensure_init();
307-
let len = match fgetxattr(fd, c"user.mime_type", mime_type.init_mut()) {
306+
let len = match fgetxattr(fd, c"user.mime_type", mime_type.uninit_mut()) {
308307
Err(Errno::NODATA) => return Ok(MimeType::new_const()),
309308
r => r.map_io_err(|| "Failed to read extended attributes.")?,
310-
};
311-
mime_type.advance(len);
309+
}
310+
.0
311+
.len();
312+
unsafe {
313+
mime_type.advance_unchecked(len);
314+
}
312315
}
313316
let mime_type = str::from_utf8(mime_type.filled()).map_err(|e| ringboard_core::Error::Io {
314317
error: io::Error::new(ErrorKind::InvalidInput, e),

core/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ arrayvec = "0.7.6"
1414
dirs = "6.0.0"
1515
error-stack = { version = "0.5.0", default-features = false, optional = true }
1616
itoa = "1.0.14"
17-
rustix = { version = "0.38.44", features = ["fs", "mm", "process", "net", "event", "itoa", "linux_latest"] }
17+
rustix = { version = "1.0.0-prerelease.1", features = ["fs", "mm", "process", "net", "event", "linux_latest"] }
1818
thiserror = "2.0.11"
1919

2020
[dev-dependencies]

0 commit comments

Comments
 (0)