Skip to content

Commit

Permalink
refactor: use style_edition 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Sep 28, 2024
1 parent 982e993 commit c2894bc
Show file tree
Hide file tree
Showing 82 changed files with 236 additions and 230 deletions.
2 changes: 1 addition & 1 deletion compio-buf/src/io_vec_buf.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::ops::{Deref, DerefMut};

use crate::{
t_alloc, IndexedIter, IoBuf, IoBufMut, IoSlice, IoSliceMut, OwnedIterator, SetBufInit,
IndexedIter, IoBuf, IoBufMut, IoSlice, IoSliceMut, OwnedIterator, SetBufInit, t_alloc,
};

/// A type that's either owned or borrowed. Like [`Cow`](std::rc::Cow) but
Expand Down
6 changes: 3 additions & 3 deletions compio-dispatcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use std::{
num::NonZeroUsize,
panic::resume_unwind,
sync::{Arc, Mutex},
thread::{available_parallelism, JoinHandle},
thread::{JoinHandle, available_parallelism},
};

use compio_driver::{AsyncifyPool, DispatchError, Dispatchable, ProactorBuilder};
use compio_runtime::{event::Event, JoinHandle as CompioJoinHandle, Runtime};
use flume::{unbounded, Sender};
use compio_runtime::{JoinHandle as CompioJoinHandle, Runtime, event::Event};
use flume::{Sender, unbounded};
use futures_channel::oneshot;

type Spawning = Box<dyn Spawnable + Send>;
Expand Down
2 changes: 1 addition & 1 deletion compio-dispatcher/tests/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use compio_dispatcher::Dispatcher;
use compio_io::{AsyncReadExt, AsyncWriteExt};
use compio_net::{TcpListener, TcpStream};
use compio_runtime::spawn;
use futures_util::{stream::FuturesUnordered, StreamExt};
use futures_util::{StreamExt, stream::FuturesUnordered};

#[compio_macros::test]
async fn listener_dispatch() {
Expand Down
4 changes: 2 additions & 2 deletions compio-driver/src/asyncify.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::{
fmt,
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
atomic::{AtomicUsize, Ordering},
},
time::Duration,
};

use crossbeam_channel::{bounded, Receiver, Sender, TrySendError};
use crossbeam_channel::{Receiver, Sender, TrySendError, bounded};

/// An error that may be emitted when all worker threads are busy. It simply
/// returns the dispatchable value with a convenient [`fmt::Debug`] and
Expand Down
4 changes: 2 additions & 2 deletions compio-driver/src/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::os::fd::FromRawFd;
#[cfg(windows)]
use std::os::windows::io::{FromRawHandle, FromRawSocket, RawHandle, RawSocket};
use std::{
future::{poll_fn, Future},
future::{Future, poll_fn},
mem::ManuallyDrop,
ops::Deref,
panic::RefUnwindSafe,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
atomic::{AtomicBool, Ordering},
},
task::Poll,
};
Expand Down
2 changes: 1 addition & 1 deletion compio-driver/src/fusion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub(crate) mod op;
pub use std::os::fd::{AsRawFd, OwnedFd, RawFd};
use std::{io, task::Poll, time::Duration};

pub(crate) use iour::{sockaddr_storage, socklen_t};
pub use iour::{OpCode as IourOpCode, OpEntry};
pub(crate) use iour::{sockaddr_storage, socklen_t};
pub use poll::{Decision, OpCode as PollOpCode};

pub use crate::driver_type::DriverType; // Re-export so current user won't be broken
Expand Down
2 changes: 1 addition & 1 deletion compio-driver/src/fusion/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use compio_buf::{IntoInner, IoBuf, IoBufMut, IoVectoredBuf, IoVectoredBufMut};
use socket2::SockAddr;

use super::*;
pub use crate::unix::op::*;
use crate::SharedFd;
pub use crate::unix::op::*;

macro_rules! op {
(<$($ty:ident: $trait:ident),* $(,)?> $name:ident( $($arg:ident: $arg_t:ty),* $(,)? )) => {
Expand Down
2 changes: 1 addition & 1 deletion compio-driver/src/iocp/cp/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use once_cell::sync::OnceCell as OnceLock;
use windows_sys::Win32::System::IO::PostQueuedCompletionStatus;

use super::CompletionPort;
use crate::{syscall, Entry, Overlapped, RawFd};
use crate::{Entry, Overlapped, RawFd, syscall};

struct GlobalPort {
port: CompletionPort,
Expand Down
16 changes: 8 additions & 8 deletions compio-driver/src/iocp/cp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ use std::{
use compio_log::*;
use windows_sys::Win32::{
Foundation::{
RtlNtStatusToDosError, ERROR_BAD_COMMAND, ERROR_BROKEN_PIPE, ERROR_HANDLE_EOF,
ERROR_IO_INCOMPLETE, ERROR_NO_DATA, ERROR_PIPE_CONNECTED, ERROR_PIPE_NOT_CONNECTED,
FACILITY_NTWIN32, INVALID_HANDLE_VALUE, NTSTATUS, STATUS_PENDING, STATUS_SUCCESS,
ERROR_BAD_COMMAND, ERROR_BROKEN_PIPE, ERROR_HANDLE_EOF, ERROR_IO_INCOMPLETE, ERROR_NO_DATA,
ERROR_PIPE_CONNECTED, ERROR_PIPE_NOT_CONNECTED, FACILITY_NTWIN32, INVALID_HANDLE_VALUE,
NTSTATUS, RtlNtStatusToDosError, STATUS_PENDING, STATUS_SUCCESS,
},
Storage::FileSystem::SetFileCompletionNotificationModes,
System::{
IO::{
CreateIoCompletionPort, GetQueuedCompletionStatusEx, OVERLAPPED_ENTRY,
PostQueuedCompletionStatus,
},
SystemServices::ERROR_SEVERITY_ERROR,
Threading::INFINITE,
WindowsProgramming::{FILE_SKIP_COMPLETION_PORT_ON_SUCCESS, FILE_SKIP_SET_EVENT_ON_HANDLE},
IO::{
CreateIoCompletionPort, GetQueuedCompletionStatusEx, PostQueuedCompletionStatus,
OVERLAPPED_ENTRY,
},
},
};

use crate::{syscall, Entry, Overlapped, RawFd};
use crate::{Entry, Overlapped, RawFd, syscall};

cfg_if::cfg_if! {
if #[cfg(feature = "iocp-global")] {
Expand Down
12 changes: 6 additions & 6 deletions compio-driver/src/iocp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ use std::{
use compio_log::{instrument, trace};
use windows_sys::Win32::{
Foundation::{ERROR_BUSY, ERROR_TIMEOUT, WAIT_OBJECT_0, WAIT_TIMEOUT},
Networking::WinSock::{WSACleanup, WSAStartup, WSADATA},
Networking::WinSock::{WSACleanup, WSADATA, WSAStartup},
System::{
IO::OVERLAPPED,
Threading::{
CloseThreadpoolWait, CreateThreadpoolWait, SetThreadpoolWait,
WaitForThreadpoolWaitCallbacks, PTP_CALLBACK_INSTANCE, PTP_WAIT,
CloseThreadpoolWait, CreateThreadpoolWait, PTP_CALLBACK_INSTANCE, PTP_WAIT,
SetThreadpoolWait, WaitForThreadpoolWaitCallbacks,
},
IO::OVERLAPPED,
},
};

use crate::{syscall, AsyncifyPool, Entry, Key, OutEntries, ProactorBuilder};
use crate::{AsyncifyPool, Entry, Key, OutEntries, ProactorBuilder, syscall};

pub(crate) mod op;

mod cp;

pub(crate) use windows_sys::Win32::Networking::WinSock::{
socklen_t, SOCKADDR_STORAGE as sockaddr_storage,
SOCKADDR_STORAGE as sockaddr_storage, socklen_t,
};

/// On windows, handle and socket are in the same size.
Expand Down
32 changes: 16 additions & 16 deletions compio-driver/src/iocp/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@ use std::{
task::Poll,
};

use aligned_array::{Aligned, A8};
use aligned_array::{A8, Aligned};
use compio_buf::{
BufResult, IntoInner, IoBuf, IoBufMut, IoSlice, IoSliceMut, IoVectoredBuf, IoVectoredBufMut,
};
#[cfg(not(feature = "once_cell_try"))]
use once_cell::sync::OnceCell as OnceLock;
use socket2::SockAddr;
use windows_sys::{
core::GUID,
Win32::{
Foundation::{
CloseHandle, GetLastError, ERROR_BROKEN_PIPE, ERROR_HANDLE_EOF, ERROR_IO_INCOMPLETE,
ERROR_IO_PENDING, ERROR_NOT_FOUND, ERROR_NO_DATA, ERROR_PIPE_CONNECTED,
ERROR_PIPE_NOT_CONNECTED,
CloseHandle, ERROR_BROKEN_PIPE, ERROR_HANDLE_EOF, ERROR_IO_INCOMPLETE,
ERROR_IO_PENDING, ERROR_NO_DATA, ERROR_NOT_FOUND, ERROR_PIPE_CONNECTED,
ERROR_PIPE_NOT_CONNECTED, GetLastError,
},
Networking::WinSock::{
closesocket, setsockopt, shutdown, socklen_t, WSAIoctl, WSARecv, WSARecvFrom, WSASend,
WSASendMsg, WSASendTo, CMSGHDR, LPFN_ACCEPTEX, LPFN_CONNECTEX,
LPFN_GETACCEPTEXSOCKADDRS, LPFN_WSARECVMSG, SD_BOTH, SD_RECEIVE, SD_SEND,
SIO_GET_EXTENSION_FUNCTION_POINTER, SOCKADDR, SOCKADDR_STORAGE, SOL_SOCKET,
SO_UPDATE_ACCEPT_CONTEXT, SO_UPDATE_CONNECT_CONTEXT, WSABUF, WSAID_ACCEPTEX,
WSAID_CONNECTEX, WSAID_GETACCEPTEXSOCKADDRS, WSAID_WSARECVMSG, WSAMSG,
CMSGHDR, LPFN_ACCEPTEX, LPFN_CONNECTEX, LPFN_GETACCEPTEXSOCKADDRS, LPFN_WSARECVMSG,
SD_BOTH, SD_RECEIVE, SD_SEND, SIO_GET_EXTENSION_FUNCTION_POINTER,
SO_UPDATE_ACCEPT_CONTEXT, SO_UPDATE_CONNECT_CONTEXT, SOCKADDR, SOCKADDR_STORAGE,
SOL_SOCKET, WSABUF, WSAID_ACCEPTEX, WSAID_CONNECTEX, WSAID_GETACCEPTEXSOCKADDRS,
WSAID_WSARECVMSG, WSAIoctl, WSAMSG, WSARecv, WSARecvFrom, WSASend, WSASendMsg,
WSASendTo, closesocket, setsockopt, shutdown, socklen_t,
},
Storage::FileSystem::{FlushFileBuffers, ReadFile, WriteFile},
System::{
Pipes::ConnectNamedPipe,
IO::{CancelIoEx, OVERLAPPED},
Pipes::ConnectNamedPipe,
},
},
core::GUID,
};

use crate::{op::*, syscall, AsRawFd, OpCode, OpType, RawFd, SharedFd};
use crate::{AsRawFd, OpCode, OpType, RawFd, SharedFd, op::*, syscall};

#[inline]
fn winapi_result(transferred: u32) -> Poll<io::Result<usize>> {
Expand Down Expand Up @@ -112,9 +112,9 @@ fn get_wsa_fn<F>(handle: RawFd, fguid: GUID) -> io::Result<Option<F>> {
}

impl<
D: std::marker::Send + 'static,
F: (FnOnce() -> BufResult<usize, D>) + std::marker::Send + std::marker::Sync + 'static,
> OpCode for Asyncify<F, D>
D: std::marker::Send + 'static,
F: (FnOnce() -> BufResult<usize, D>) + std::marker::Send + std::marker::Sync + 'static,
> OpCode for Asyncify<F, D>
{
fn op_type(&self) -> OpType {
OpType::Blocking
Expand Down
4 changes: 2 additions & 2 deletions compio-driver/src/iour/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ cfg_if::cfg_if! {
}
}
use io_uring::{
IoUring,
cqueue::more,
opcode::{AsyncCancel, PollAdd},
types::{Fd, SubmitArgs, Timespec},
IoUring,
};
pub(crate) use libc::{sockaddr_storage, socklen_t};

use crate::{syscall, AsyncifyPool, Entry, Key, OutEntries, ProactorBuilder};
use crate::{AsyncifyPool, Entry, Key, OutEntries, ProactorBuilder, syscall};

pub(crate) mod op;

Expand Down
8 changes: 4 additions & 4 deletions compio-driver/src/iour/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ use socket2::SockAddr;

use super::OpCode;
pub use crate::unix::op::*;
use crate::{op::*, syscall, OpEntry, SharedFd};
use crate::{OpEntry, SharedFd, op::*, syscall};

impl<
D: std::marker::Send + 'static,
F: (FnOnce() -> BufResult<usize, D>) + std::marker::Send + std::marker::Sync + 'static,
> OpCode for Asyncify<F, D>
D: std::marker::Send + 'static,
F: (FnOnce() -> BufResult<usize, D>) + std::marker::Send + std::marker::Sync + 'static,
> OpCode for Asyncify<F, D>
{
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
OpEntry::Blocking
Expand Down
2 changes: 1 addition & 1 deletion compio-driver/src/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ pub use crate::sys::op::{
ReadVectoredAt, Rename, Symlink, Unlink, WriteVectoredAt,
};
use crate::{
sys::{sockaddr_storage, socklen_t},
OwnedFd, SharedFd,
sys::{sockaddr_storage, socklen_t},
};

/// Trait to update the buffer length inside the [`BufResult`].
Expand Down
2 changes: 1 addition & 1 deletion compio-driver/src/poll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crossbeam_queue::SegQueue;
pub(crate) use libc::{sockaddr_storage, socklen_t};
use polling::{Event, Events, PollMode, Poller};

use crate::{op::Interest, syscall, AsyncifyPool, Entry, Key, OutEntries, ProactorBuilder};
use crate::{AsyncifyPool, Entry, Key, OutEntries, ProactorBuilder, op::Interest, syscall};

pub(crate) mod op;

Expand Down
10 changes: 5 additions & 5 deletions compio-driver/src/poll/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ use libc::{pread64 as pread, preadv64 as preadv, pwrite64 as pwrite, pwritev64 a
use polling::Event;
use socket2::SockAddr;

use super::{sockaddr_storage, socklen_t, syscall, AsRawFd, Decision, OpCode};
use super::{AsRawFd, Decision, OpCode, sockaddr_storage, socklen_t, syscall};
pub use crate::unix::op::*;
use crate::{op::*, SharedFd};
use crate::{SharedFd, op::*};

impl<
D: std::marker::Send + 'static,
F: (FnOnce() -> BufResult<usize, D>) + std::marker::Send + std::marker::Sync + 'static,
> OpCode for Asyncify<F, D>
D: std::marker::Send + 'static,
F: (FnOnce() -> BufResult<usize, D>) + std::marker::Send + std::marker::Sync + 'static,
> OpCode for Asyncify<F, D>
{
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision> {
Ok(Decision::blocking_dummy())
Expand Down
2 changes: 1 addition & 1 deletion compio-driver/src/unix/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use compio_buf::{
use libc::{sockaddr_storage, socklen_t};
use socket2::SockAddr;

use crate::{op::*, SharedFd};
use crate::{SharedFd, op::*};

/// Open or create a file with flags and mode.
pub struct OpenFile {
Expand Down
4 changes: 2 additions & 2 deletions compio-driver/tests/file.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::{io, time::Duration};

use compio_buf::{arrayvec::ArrayVec, BufResult};
use compio_buf::{BufResult, arrayvec::ArrayVec};
use compio_driver::{
op::{Asyncify, CloseFile, ReadAt},
AsRawFd, OpCode, OwnedFd, Proactor, PushEntry, SharedFd,
op::{Asyncify, CloseFile, ReadAt},
};

#[cfg(windows)]
Expand Down
2 changes: 1 addition & 1 deletion compio-fs/src/async_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use std::os::windows::io::{

use compio_buf::{BufResult, IntoInner, IoBuf, IoBufMut};
use compio_driver::{
op::{BufResultExt, Recv, Send},
AsRawFd, SharedFd, ToSharedFd,
op::{BufResultExt, Recv, Send},
};
use compio_io::{AsyncRead, AsyncWrite};
use compio_runtime::Attacher;
Expand Down
5 changes: 2 additions & 3 deletions compio-fs/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use std::{future::Future, io, mem::ManuallyDrop, panic::resume_unwind, path::Pat

use compio_buf::{BufResult, IntoInner, IoBuf, IoBufMut};
use compio_driver::{
impl_raw_fd,
ToSharedFd, impl_raw_fd,
op::{BufResultExt, CloseFile, ReadAt, Sync, WriteAt},
ToSharedFd,
};
use compio_io::{AsyncReadAt, AsyncWriteAt};
use compio_runtime::Attacher;
Expand Down Expand Up @@ -108,7 +107,7 @@ impl File {
pub async fn set_permissions(&self, perm: Permissions) -> io::Result<()> {
use std::os::unix::fs::PermissionsExt;

use compio_driver::{syscall, AsRawFd};
use compio_driver::{AsRawFd, syscall};

let file = self.inner.clone();
compio_runtime::spawn_blocking(move || {
Expand Down
6 changes: 3 additions & 3 deletions compio-fs/src/named_pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::ptr::null_mut;
use std::{ffi::OsStr, io, os::windows::io::FromRawHandle, ptr::null};

use compio_buf::{BufResult, IoBuf, IoBufMut};
use compio_driver::{impl_raw_fd, op::ConnectNamedPipe, syscall, AsRawFd, RawFd, ToSharedFd};
use compio_driver::{AsRawFd, RawFd, ToSharedFd, impl_raw_fd, op::ConnectNamedPipe, syscall};
use compio_io::{AsyncRead, AsyncReadAt, AsyncWrite, AsyncWriteAt};
use widestring::U16CString;
use windows_sys::Win32::{
Expand Down Expand Up @@ -715,7 +715,7 @@ impl ServerOptions {
/// use windows_sys::Win32::{
/// Foundation::ERROR_SUCCESS,
/// Security::{
/// Authorization::{SetSecurityInfo, SE_KERNEL_OBJECT},
/// Authorization::{SE_KERNEL_OBJECT, SetSecurityInfo},
/// DACL_SECURITY_INFORMATION,
/// },
/// };
Expand Down Expand Up @@ -752,7 +752,7 @@ impl ServerOptions {
/// use windows_sys::Win32::{
/// Foundation::ERROR_ACCESS_DENIED,
/// Security::{
/// Authorization::{SetSecurityInfo, SE_KERNEL_OBJECT},
/// Authorization::{SE_KERNEL_OBJECT, SetSecurityInfo},
/// DACL_SECURITY_INFORMATION,
/// },
/// };
Expand Down
4 changes: 2 additions & 2 deletions compio-fs/src/open_options/unix.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{io, os::fd::FromRawFd, path::Path};

use compio_driver::{op::OpenFile, RawFd};
use compio_driver::{RawFd, op::OpenFile};

use crate::{path_string, File};
use crate::{File, path_string};

#[derive(Clone, Debug)]
pub struct OpenOptions {
Expand Down
4 changes: 2 additions & 2 deletions compio-fs/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use std::{

use compio_buf::{BufResult, IntoInner, IoBuf, IoBufMut, IoVectoredBuf, IoVectoredBufMut};
use compio_driver::{
impl_raw_fd,
AsRawFd, ToSharedFd, impl_raw_fd,
op::{BufResultExt, Recv, RecvVectored, Send, SendVectored},
syscall, AsRawFd, ToSharedFd,
syscall,
};
use compio_io::{AsyncRead, AsyncWrite};

Expand Down
Loading

0 comments on commit c2894bc

Please sign in to comment.