diff --git a/src/ffi/body.rs b/src/ffi/body.rs index 89f1ad3dd3..fa99e61803 100644 --- a/src/ffi/body.rs +++ b/src/ffi/body.rs @@ -7,8 +7,8 @@ use http_body_util::BodyExt as _; use libc::{c_int, size_t}; use super::task::{hyper_context, hyper_task, hyper_task_return_type, AsTaskType}; +use super::userdata::{hyper_userdata_drop, Userdata}; use super::HYPER_ITER_CONTINUE; -use super::userdata::{Userdata, hyper_userdata_drop}; use crate::body::{Bytes, Frame, Incoming as IncomingBody}; /// A streaming HTTP body. diff --git a/src/ffi/client.rs b/src/ffi/client.rs index d1c078cadc..d58a0e2449 100644 --- a/src/ffi/client.rs +++ b/src/ffi/client.rs @@ -1,6 +1,6 @@ +use std::pin::Pin; use std::ptr; use std::sync::Arc; -use std::pin::Pin; use libc::c_int; diff --git a/src/ffi/http_types.rs b/src/ffi/http_types.rs index 22f2cd700f..ae4f3f7ea9 100644 --- a/src/ffi/http_types.rs +++ b/src/ffi/http_types.rs @@ -5,8 +5,8 @@ use std::ffi::c_void; use super::body::hyper_body; use super::error::hyper_code; use super::task::{hyper_task_return_type, AsTaskType}; +use super::userdata::{hyper_userdata_drop, Userdata}; use super::HYPER_ITER_CONTINUE; -use super::userdata::{Userdata, hyper_userdata_drop}; use crate::body::Incoming as IncomingBody; use crate::ext::{HeaderCaseMap, OriginalHeaderOrder, ReasonPhrase}; use crate::header::{HeaderName, HeaderValue}; @@ -574,7 +574,6 @@ impl From> for hyper_response { } } - unsafe impl AsTaskType for hyper_response { fn as_task_type(&self) -> hyper_task_return_type { hyper_task_return_type::HYPER_TASK_RESPONSE diff --git a/src/ffi/io.rs b/src/ffi/io.rs index 0d297f8c15..c368cdcc9a 100644 --- a/src/ffi/io.rs +++ b/src/ffi/io.rs @@ -6,7 +6,7 @@ use crate::rt::{Read, Write}; use libc::size_t; use super::task::hyper_context; -use super::userdata::{Userdata, hyper_userdata_drop}; +use super::userdata::{hyper_userdata_drop, Userdata}; /// Sentinel value to return from a read or write callback that the operation /// is pending. @@ -153,7 +153,12 @@ impl Read for hyper_io { let buf_ptr = unsafe { buf.as_mut() }.as_mut_ptr() as *mut u8; let buf_len = buf.remaining(); - match (self.read)(self.userdata.as_ptr(), hyper_context::wrap(cx), buf_ptr, buf_len) { + match (self.read)( + self.userdata.as_ptr(), + hyper_context::wrap(cx), + buf_ptr, + buf_len, + ) { HYPER_IO_PENDING => Poll::Pending, HYPER_IO_ERROR => Poll::Ready(Err(std::io::Error::new( std::io::ErrorKind::Other, @@ -178,7 +183,12 @@ impl Write for hyper_io { let buf_ptr = buf.as_ptr(); let buf_len = buf.len(); - match (self.write)(self.userdata.as_ptr(), hyper_context::wrap(cx), buf_ptr, buf_len) { + match (self.write)( + self.userdata.as_ptr(), + hyper_context::wrap(cx), + buf_ptr, + buf_len, + ) { HYPER_IO_PENDING => Poll::Pending, HYPER_IO_ERROR => Poll::Ready(Err(std::io::Error::new( std::io::ErrorKind::Other, diff --git a/src/ffi/macros.rs b/src/ffi/macros.rs index 5147522943..b8937b0aa2 100644 --- a/src/ffi/macros.rs +++ b/src/ffi/macros.rs @@ -37,7 +37,9 @@ macro_rules! non_null { return $err; } #[allow(unused_unsafe)] - unsafe { $eval } + unsafe { + $eval + } }}; (*$ptr:ident ?= $err:expr) => {{ non_null!($ptr, *$ptr, $err) diff --git a/src/ffi/mod.rs b/src/ffi/mod.rs index 6213b85e6f..e8a261c261 100644 --- a/src/ffi/mod.rs +++ b/src/ffi/mod.rs @@ -39,10 +39,10 @@ mod macros; mod body; mod client; -mod server; mod error; mod http_types; mod io; +mod server; mod task; mod time; mod userdata; diff --git a/src/ffi/server.rs b/src/ffi/server.rs index 22e656e34d..9ece78652c 100644 --- a/src/ffi/server.rs +++ b/src/ffi/server.rs @@ -7,7 +7,7 @@ use crate::ffi::error::hyper_code; use crate::ffi::http_types::{hyper_request, hyper_response}; use crate::ffi::io::hyper_io; use crate::ffi::task::{hyper_executor, hyper_task, WeakExec}; -use crate::ffi::userdata::{Userdata, hyper_userdata_drop}; +use crate::ffi::userdata::{hyper_userdata_drop, Userdata}; use crate::server::conn::http1; use crate::server::conn::http2; diff --git a/src/ffi/task.rs b/src/ffi/task.rs index 3afdf419c8..5a020e071d 100644 --- a/src/ffi/task.rs +++ b/src/ffi/task.rs @@ -12,7 +12,7 @@ use futures_util::stream::{FuturesUnordered, Stream}; use libc::c_int; use super::error::hyper_code; -use super::userdata::{Userdata, hyper_userdata_drop}; +use super::userdata::{hyper_userdata_drop, Userdata}; type BoxFuture = Pin + Send>>; type BoxAny = Box; diff --git a/src/ffi/time.rs b/src/ffi/time.rs index bf9b19dede..f3f2747752 100644 --- a/src/ffi/time.rs +++ b/src/ffi/time.rs @@ -1,8 +1,8 @@ +use std::collections::binary_heap::{BinaryHeap, PeekMut}; use std::pin::Pin; use std::sync::{Arc, Mutex}; use std::task::{Context, Poll, Waker}; -use std::time::{Instant, Duration}; -use std::collections::binary_heap::{BinaryHeap, PeekMut}; +use std::time::{Duration, Instant}; /// A heap of timer entries with their associated wakers, backing `TimerFuture` instances. pub(super) struct TimerHeap(BinaryHeap); diff --git a/src/ffi/userdata.rs b/src/ffi/userdata.rs index 9197e407dd..78132cd176 100644 --- a/src/ffi/userdata.rs +++ b/src/ffi/userdata.rs @@ -21,10 +21,7 @@ pub(crate) struct Userdata { impl Userdata { pub(crate) fn new(data: *mut c_void, drop: hyper_userdata_drop) -> Self { - Self { - data, - drop, - } + Self { data, drop } } pub(crate) fn as_ptr(&self) -> *mut c_void {