Skip to content

Commit 0e1c987

Browse files
authored
chore: refactor driver module (#180)
This change renames the top-level driver module to "io" and moves the driver and Op to a driver module within the runtime module.
1 parent b1ca3aa commit 0e1c987

35 files changed

+113
-135
lines changed

src/fs/directory.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use crate::driver::Op;
2-
1+
use crate::runtime::driver::op::Op;
32
use std::io;
43
use std::path::Path;
54

src/fs/file.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::buf::{BoundedBuf, BoundedBufMut, IoBuf, IoBufMut, Slice};
2-
use crate::driver::{Op, SharedFd};
32
use crate::fs::OpenOptions;
3+
use crate::io::SharedFd;
44

5+
use crate::runtime::driver::op::Op;
56
use std::fmt;
67
use std::io;
78
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};

src/fs/open_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use crate::driver::Op;
21
use crate::fs::File;
32

3+
use crate::runtime::driver::op::Op;
44
use std::io;
55
use std::os::unix::fs::OpenOptionsExt;
66
use std::path::Path;

src/driver/accept.rs renamed to src/io/accept.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use crate::driver::op::{self, Completable};
2-
use crate::driver::{Op, SharedFd, Socket};
1+
use crate::io::{SharedFd, Socket};
2+
use crate::runtime::driver::op;
3+
use crate::runtime::driver::op::{Completable, Op};
34
use std::net::SocketAddr;
45
use std::{boxed::Box, io};
56

File renamed without changes.

src/driver/close.rs renamed to src/io/close.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use crate::driver::Op;
2-
3-
use crate::driver::op::{self, Completable};
1+
use crate::runtime::driver::op;
2+
use crate::runtime::driver::op::{Completable, Op};
43
use std::io;
54
use std::os::unix::io::RawFd;
65

src/driver/connect.rs renamed to src/io/connect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::driver::op::{self, Completable};
2-
use crate::driver::{Op, SharedFd};
1+
use crate::io::SharedFd;
2+
use crate::runtime::driver::op::{Completable, CqeResult, Op};
33
use socket2::SockAddr;
44
use std::io;
55

@@ -36,7 +36,7 @@ impl Op<Connect> {
3636
impl Completable for Connect {
3737
type Output = io::Result<()>;
3838

39-
fn complete(self, cqe: op::CqeResult) -> Self::Output {
39+
fn complete(self, cqe: CqeResult) -> Self::Output {
4040
cqe.result.map(|_| ())
4141
}
4242
}

src/driver/fsync.rs renamed to src/io/fsync.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use crate::driver::{Op, SharedFd};
2-
31
use std::io;
42

5-
use crate::driver::op::{self, Completable};
3+
use crate::io::SharedFd;
4+
use crate::runtime::driver::op::{Completable, CqeResult, Op};
65
use io_uring::{opcode, types};
76

87
pub(crate) struct Fsync {
@@ -28,7 +27,7 @@ impl Op<Fsync> {
2827
impl Completable for Fsync {
2928
type Output = io::Result<()>;
3029

31-
fn complete(self, cqe: op::CqeResult) -> Self::Output {
30+
fn complete(self, cqe: CqeResult) -> Self::Output {
3231
cqe.result.map(|_| ())
3332
}
3433
}

src/io/mod.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
mod accept;
2+
3+
mod close;
4+
pub(crate) use close::Close;
5+
6+
mod connect;
7+
8+
mod fsync;
9+
10+
mod noop;
11+
pub(crate) use noop::NoOp;
12+
13+
mod open;
14+
15+
mod read;
16+
17+
mod readv;
18+
19+
mod recv_from;
20+
21+
mod rename_at;
22+
23+
mod send_to;
24+
25+
mod send_zc;
26+
27+
mod shared_fd;
28+
pub(crate) use shared_fd::SharedFd;
29+
30+
mod socket;
31+
pub(crate) use socket::Socket;
32+
33+
mod unlink_at;
34+
35+
mod util;
36+
37+
mod write;
38+
39+
mod writev;

src/driver/noop.rs renamed to src/io/noop.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use crate::driver::{
2-
op::{self, Completable},
3-
Op,
4-
};
1+
use crate::runtime::driver::op::{Completable, CqeResult, Op};
52
use std::io;
63

74
/// No operation. Just posts a completion event, nothing else.
@@ -20,7 +17,7 @@ impl Op<NoOp> {
2017
impl Completable for NoOp {
2118
type Output = io::Result<()>;
2219

23-
fn complete(self, cqe: op::CqeResult) -> Self::Output {
20+
fn complete(self, cqe: CqeResult) -> Self::Output {
2421
cqe.result.map(|_| ())
2522
}
2623
}

0 commit comments

Comments
 (0)