Skip to content

Commit a9b3e22

Browse files
committed
chore: apply rustfmt
1 parent 87013fd commit a9b3e22

File tree

6 files changed

+25
-30
lines changed

6 files changed

+25
-30
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tokio-splice2"
3-
version = "0.3.0-alpha.9"
3+
version = "0.3.0-alpha.10"
44
edition = "2021"
55
rust-version = "1.70.0"
66

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ unstable_features = true
44

55
# imports
66
group_imports = "StdExternalCrate"
7-
imports_granularity = "Crate"
7+
imports_granularity = "Module"
88
reorder_imports = true
99

1010
# comments

src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
mod pipe;
66
mod splice;
77

8-
use std::{io, pin::Pin};
8+
use std::io;
9+
use std::pin::Pin;
910

1011
pub use splice::{AsyncReadFd, AsyncStreamFd, AsyncWriteFd, SpliceIoCtx};
1112

1213
/// Copy data from `r` to `w` using `splice(2)`.
1314
///
14-
/// [`SpliceIoCtx::copy`] is used to perform the copy operation.
15+
/// This is a convenience function that uses [`SpliceIoCtx::copy`].
1516
pub async fn copy<R, W>(r: &mut R, w: &mut W) -> io::Result<usize>
1617
where
1718
R: splice::AsyncReadFd + Unpin,
@@ -24,9 +25,12 @@ where
2425

2526
/// Copies data in both directions between `a` and `b`.
2627
///
27-
/// This function returns a future that will read from both streams,
28-
/// writing any data read to the opposing stream.
29-
/// This happens in both directions concurrently.
28+
/// This function returns a future that will read from both streams, writing any
29+
/// data read to the opposing stream. This happens in both directions
30+
/// concurrently.
31+
///
32+
/// This is a convenience function that uses
33+
/// [`SpliceIoCtx::copy_bidirectional`].
3034
pub async fn copy_bidirectional<R, W>(a: &mut R, b: &mut W) -> io::Result<(usize, usize)>
3135
where
3236
R: splice::AsyncStreamFd + Unpin,

src/pipe.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
33
use std::io;
44

5-
use rustix::{
6-
fd::OwnedFd,
7-
pipe::{fcntl_setpipe_size, pipe_with, PipeFlags},
8-
};
5+
use rustix::fd::OwnedFd;
6+
use rustix::pipe::{fcntl_setpipe_size, pipe_with, PipeFlags};
97

108
/// the size of `PIPE_BUF`
119
const PIPE_SIZE: usize = 65536;

src/splice.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,17 @@
88
//!
99
//! [Linux]: https://man7.org/linux/man-pages/man2/splice.2.html
1010
11-
use std::{
12-
cmp, fmt,
13-
future::poll_fn,
14-
io,
15-
marker::PhantomData,
16-
os::fd::AsFd,
17-
pin::{pin, Pin},
18-
task::{ready, Context, Poll},
19-
};
11+
use std::future::poll_fn;
12+
use std::marker::PhantomData;
13+
use std::os::fd::AsFd;
14+
use std::pin::{pin, Pin};
15+
use std::task::{ready, Context, Poll};
16+
use std::{cmp, fmt, io};
2017

2118
use rustix::pipe::{splice, SpliceFlags};
22-
use tokio::{
23-
fs::File,
24-
io::{AsyncRead, AsyncWrite, Interest},
25-
net::{TcpStream, UnixStream},
26-
};
19+
use tokio::fs::File;
20+
use tokio::io::{AsyncRead, AsyncWrite, Interest};
21+
use tokio::net::{TcpStream, UnixStream};
2722

2823
use crate::pipe::Pipe;
2924

tests/test.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
33
use std::io::Result;
44

5-
use tokio::{
6-
io::{AsyncReadExt, AsyncWriteExt},
7-
net::{TcpListener, TcpStream},
8-
task,
9-
};
5+
use tokio::io::{AsyncReadExt, AsyncWriteExt};
6+
use tokio::net::{TcpListener, TcpStream};
7+
use tokio::task;
108
use tokio_splice2::copy_bidirectional;
119

1210
async fn echo_server(addr: &str) -> Result<()> {

0 commit comments

Comments
 (0)