Skip to content

Commit

Permalink
Appease the formatting gods
Browse files Browse the repository at this point in the history
  • Loading branch information
bossmc committed Oct 12, 2023
1 parent 9b4c651 commit caafc3e
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/ffi/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/ffi/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::pin::Pin;
use std::ptr;
use std::sync::Arc;
use std::pin::Pin;

use libc::c_int;

Expand Down
3 changes: 1 addition & 2 deletions src/ffi/http_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -574,7 +574,6 @@ impl From<Response<IncomingBody>> 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
Expand Down
16 changes: 13 additions & 3 deletions src/ffi/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/ffi/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ffi/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/ffi/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = Pin<Box<dyn Future<Output = T> + Send>>;
type BoxAny = Box<dyn AsTaskType + Send + Sync>;
Expand Down
4 changes: 2 additions & 2 deletions src/ffi/time.rs
Original file line number Diff line number Diff line change
@@ -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<TimerEntry>);
Expand Down
5 changes: 1 addition & 4 deletions src/ffi/userdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit caafc3e

Please sign in to comment.