From 088e58289155fa4a8cce2c4f96ed24a661ad364d Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Mon, 28 Feb 2022 21:41:37 +0000 Subject: [PATCH] Switch from pin-project to pin-project-lite This is another small step towards reducing the size of bollard's dependency tree :-) `tokio` and `hyper` have both switched from `pin-project` crate to the lighter-weight `pin-project-lite`: https://github.com/tokio-rs/tokio/pull/1778 https://github.com/hyperium/hyper/pull/2566 This does the same for bollard. For the differences between the two crates, see: https://docs.rs/pin-project-lite/0.2.8/pin_project_lite/#pin-project-vs-pin-project-lite Note: The full advantage of this won't be seen until a new `hyperlocal` release exists that contains: https://github.com/softprops/hyperlocal/pull/54 ...and bollard updates to that release, so that `pin-project` can be fully dropped from the dependency tree. --- Cargo.toml | 2 +- src/named_pipe.rs | 11 ++++++----- src/read.rs | 24 +++++++++++++----------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index df42eb68..3e0a6149 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ http = "0.2" hyper = { version = "0.14", features = ["client", "tcp", "http1", "http2", "stream"] } hyper-rustls = { version = "0.23", optional = true } log = "0.4" -pin-project = "1.0.2" +pin-project-lite = "0.2.8" rustls = { version = "0.20", optional = true } rustls-native-certs = { version = "0.6.0", optional = true } rustls-pemfile = { version = "0.2", optional = true } diff --git a/src/named_pipe.rs b/src/named_pipe.rs index 346ab26a..3f7ca2da 100644 --- a/src/named_pipe.rs +++ b/src/named_pipe.rs @@ -1,7 +1,7 @@ #![cfg(windows)] use hyper::client::connect::Connected; -use pin_project::pin_project; +use pin_project_lite::pin_project; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio::net::windows::named_pipe::{ClientOptions, NamedPipeClient}; use tokio::time; @@ -19,10 +19,11 @@ use winapi::shared::winerror; use crate::docker::ClientType; use crate::uri::Uri; -#[pin_project] -pub struct NamedPipeStream { - #[pin] - io: NamedPipeClient, +pin_project! { + pub struct NamedPipeStream { + #[pin] + io: NamedPipeClient, + } } impl NamedPipeStream { diff --git a/src/read.rs b/src/read.rs index 9ea21d3a..6a26684c 100644 --- a/src/read.rs +++ b/src/read.rs @@ -2,7 +2,7 @@ use bytes::Buf; use bytes::BytesMut; use futures_core::Stream; use hyper::body::Bytes; -use pin_project::pin_project; +use pin_project_lite::pin_project; use serde::de::DeserializeOwned; use std::pin::Pin; use std::string::String; @@ -90,10 +90,11 @@ impl Decoder for NewlineLogOutputDecoder { } } -#[pin_project] -#[derive(Debug)] -pub(crate) struct JsonLineDecoder { - ty: PhantomData, +pin_project! { + #[derive(Debug)] + pub(crate) struct JsonLineDecoder { + ty: PhantomData, + } } impl JsonLineDecoder { @@ -174,12 +175,13 @@ enum ReadState { NotReady, } -#[pin_project] -#[derive(Debug)] -pub(crate) struct StreamReader { - #[pin] - stream: S, - state: ReadState, +pin_project! { + #[derive(Debug)] + pub(crate) struct StreamReader { + #[pin] + stream: S, + state: ReadState, + } } impl StreamReader