Skip to content

Commit

Permalink
delete dup rustfmt config file and resolve rustfmt depr warnings. fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
softprops committed May 5, 2024
1 parent adf3588 commit 6409d89
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
5 changes: 0 additions & 5 deletions .rustfmt.toml

This file was deleted.

8 changes: 4 additions & 4 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#fn_args_layout
fn_args_layout = "Vertical"
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#merge_imports
merge_imports = true
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#fn_params_layout
fn_params_layout = "Vertical"
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#imports_granularity
imports_granularity = "Crate"
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#format_code_in_doc_comments
format_code_in_doc_comments = true
36 changes: 27 additions & 9 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,17 @@ impl AsyncWrite for UnixStream {
self.project().unix_stream.poll_write(cx, buf)
}

fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), io::Error>> {
self.project().unix_stream.poll_flush(cx)
}

fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
fn poll_shutdown(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), io::Error>> {
self.project().unix_stream.poll_shutdown(cx)
}
}
Expand All @@ -61,11 +67,17 @@ impl hyper::rt::Write for UnixStream {
self.project().unix_stream.poll_write(cx, buf)
}

fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>> {
fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>> {
self.project().unix_stream.poll_flush(cx)
}

fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>> {
fn poll_shutdown(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>> {
self.project().unix_stream.poll_shutdown(cx)
}
}
Expand Down Expand Up @@ -98,12 +110,12 @@ impl hyper::rt::Read for UnixStream {
/// ```
/// use http_body_util::Full;
/// use hyper::body::Bytes;
/// use hyper_util::client::legacy::Client;
/// use hyper_util::rt::TokioExecutor;
/// use hyper_util::{client::legacy::Client, rt::TokioExecutor};
/// use hyperlocal::UnixConnector;
///
/// let connector = UnixConnector;
/// let client: Client<UnixConnector, Full<Bytes>> = Client::builder(TokioExecutor::new()).build(connector);
/// let client: Client<UnixConnector, Full<Bytes>> =
/// Client::builder(TokioExecutor::new()).build(connector);
/// ```
///
/// # Note
Expand All @@ -121,7 +133,10 @@ impl Service<Uri> for UnixConnector {
type Future =
Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send + 'static>>;

fn call(&mut self, req: Uri) -> Self::Future {
fn call(
&mut self,
req: Uri,
) -> Self::Future {
let fut = async move {
let path = parse_socket_path(&req)?;
UnixStream::connect(path).await
Expand All @@ -130,7 +145,10 @@ impl Service<Uri> for UnixConnector {
Box::pin(fut)
}

fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::path::Path;
///
/// # Example
/// ```
/// use hyperlocal::Uri;
/// use hyper::Uri as HyperUri;
/// use hyperlocal::Uri;
///
/// let uri: HyperUri = Uri::new("/tmp/hyperlocal.sock", "/").into();
/// ```
Expand All @@ -22,7 +22,10 @@ impl Uri {
///
/// # Panics
/// Will panic if path is not absolute and/or a malformed path string.
pub fn new(socket: impl AsRef<Path>, path: &str) -> Self {
pub fn new(
socket: impl AsRef<Path>,
path: &str,
) -> Self {
let host = hex::encode(socket.as_ref().to_string_lossy().as_bytes());
let host_str = format!("unix://{host}:0{path}");
let hyper_uri: HyperUri = host_str.parse().unwrap();
Expand Down

0 comments on commit 6409d89

Please sign in to comment.