Skip to content

Commit

Permalink
refactor: update rustfmt config
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Sep 27, 2024
1 parent 90482ab commit 982e993
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 62 deletions.
6 changes: 3 additions & 3 deletions compio-driver/src/iocp/op.rs
Original file line number Diff line number Diff line change
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
6 changes: 3 additions & 3 deletions compio-driver/src/iour/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pub use crate::unix::op::*;
use crate::{op::*, syscall, OpEntry, SharedFd};

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
6 changes: 3 additions & 3 deletions compio-driver/src/poll/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ pub use crate::unix::op::*;
use crate::{op::*, SharedFd};

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
12 changes: 5 additions & 7 deletions compio-fs/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,11 @@ async fn build_dir_mode_read_only() {
.await
.unwrap();

assert!(
compio_fs::metadata(new_dir)
.await
.expect("metadata result")
.permissions()
.readonly()
);
assert!(compio_fs::metadata(new_dir)
.await
.expect("metadata result")
.permissions()
.readonly());
}

#[compio_macros::test]
Expand Down
6 changes: 3 additions & 3 deletions compio-io/tests/io.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::io::Cursor;

use compio_buf::{BufResult, IoBuf, IoBufMut, arrayvec::ArrayVec};
use compio_buf::{arrayvec::ArrayVec, BufResult, IoBuf, IoBufMut};
use compio_io::{
AsyncRead, AsyncReadAt, AsyncReadAtExt, AsyncReadExt, AsyncWrite, AsyncWriteAt,
AsyncWriteAtExt, AsyncWriteExt, split,
split, AsyncRead, AsyncReadAt, AsyncReadAtExt, AsyncReadExt, AsyncWrite, AsyncWriteAt,
AsyncWriteAtExt, AsyncWriteExt,
};
use futures_executor::block_on;

Expand Down
4 changes: 2 additions & 2 deletions compio-quic/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,15 +1157,15 @@ pub(crate) mod h3_impl {
cx: &mut Context<'_>,
) -> Poll<Result<Self::BidiStream, Self::OpenError>> {
let (stream, is_0rtt) = ready!(self.0.poll_open_stream(Some(cx), Dir::Bi))?;
Poll::Ready(Ok(BidiStream::new(self.0.0.clone(), stream, is_0rtt)))
Poll::Ready(Ok(BidiStream::new(self.0 .0.clone(), stream, is_0rtt)))
}

fn poll_open_send(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<Self::SendStream, Self::OpenError>> {
let (stream, is_0rtt) = ready!(self.0.poll_open_stream(Some(cx), Dir::Uni))?;
Poll::Ready(Ok(SendStream::new(self.0.0.clone(), stream, is_0rtt)))
Poll::Ready(Ok(SendStream::new(self.0 .0.clone(), stream, is_0rtt)))
}

fn close(&mut self, code: Code, reason: &[u8]) {
Expand Down
27 changes: 13 additions & 14 deletions compio-quic/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,19 @@ impl EndpointInner {
async fn run(&self) -> io::Result<()> {
let respond_fn = |buf: Vec<u8>, transmit: Transmit| self.respond(buf, transmit);

let mut recv_fut = pin!(
self.socket
.recv(Vec::with_capacity(
self.state
.lock()
.unwrap()
.endpoint
.config()
.get_max_udp_payload_size()
.min(64 * 1024) as usize
* self.socket.max_gro_segments(),
))
.fuse()
);
let mut recv_fut = pin!(self
.socket
.recv(Vec::with_capacity(
self.state
.lock()
.unwrap()
.endpoint
.config()
.get_max_udp_payload_size()
.min(64 * 1024) as usize
* self.socket.max_gro_segments(),
))
.fuse());

let mut event_stream = self.events.1.stream().ready_chunks(100);

Expand Down
43 changes: 18 additions & 25 deletions compio-quic/src/send_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,12 @@ impl SendStream {
/// This operation is *not* cancel-safe.
pub async fn write_all(&mut self, buf: &[u8]) -> Result<(), WriteError> {
let mut count = 0;
poll_fn(|cx| {
loop {
if count == buf.len() {
return Poll::Ready(Ok(()));
}
let n =
ready!(self.execute_poll_write(cx, |mut stream| stream.write(&buf[count..])))?;
count += n;
poll_fn(|cx| loop {
if count == buf.len() {
return Poll::Ready(Ok(()));
}
let n = ready!(self.execute_poll_write(cx, |mut stream| stream.write(&buf[count..])))?;
count += n;
})
.await
}
Expand All @@ -224,16 +221,14 @@ impl SendStream {
/// This operation is *not* cancel-safe.
pub async fn write_all_chunks(&mut self, bufs: &mut [Bytes]) -> Result<(), WriteError> {
let mut chunks = 0;
poll_fn(|cx| {
loop {
if chunks == bufs.len() {
return Poll::Ready(Ok(()));
}
let written = ready!(self.execute_poll_write(cx, |mut stream| {
stream.write_chunks(&mut bufs[chunks..])
}))?;
chunks += written.chunks;
poll_fn(|cx| loop {
if chunks == bufs.len() {
return Poll::Ready(Ok(()));
}
let written = ready!(self.execute_poll_write(cx, |mut stream| {
stream.write_chunks(&mut bufs[chunks..])
}))?;
chunks += written.chunks;
})
.await
}
Expand Down Expand Up @@ -413,10 +408,9 @@ pub(crate) mod h3_impl {
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
if let Some(data) = &mut self.buf {
while data.has_remaining() {
let n = ready!(
self.inner
.execute_poll_write(cx, |mut stream| stream.write(data.chunk()))
)?;
let n = ready!(self
.inner
.execute_poll_write(cx, |mut stream| stream.write(data.chunk())))?;
data.advance(n);
}
}
Expand Down Expand Up @@ -462,10 +456,9 @@ pub(crate) mod h3_impl {
"poll_send called while send stream is not ready"
);

let n = ready!(
self.inner
.execute_poll_write(cx, |mut stream| stream.write(buf.chunk()))
)?;
let n = ready!(self
.inner
.execute_poll_write(cx, |mut stream| stream.write(buf.chunk())))?;
buf.advance(n);
Poll::Ready(Ok(n))
}
Expand Down
6 changes: 5 additions & 1 deletion compio-runtime/src/runtime/send_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ impl<T> SendWrapper<T> {
/// Returns a reference to the contained value, if valid.
#[inline]
pub fn get(&self) -> Option<&T> {
if self.valid() { Some(&self.data) } else { None }
if self.valid() {
Some(&self.data)
} else {
None
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
unstable_features = true

version = "Two"
style_edition = "2021"

group_imports = "StdExternalCrate"
imports_granularity = "Crate"
Expand Down

0 comments on commit 982e993

Please sign in to comment.