From 6924d1c7eade73b6d833cf6353725623f023677f Mon Sep 17 00:00:00 2001 From: Pawel Chojnacki Date: Tue, 12 Apr 2022 18:45:16 +0200 Subject: [PATCH] Make pin_project_lite usage compile on windows --- .github/actions/cache/action.yaml | 4 +-- Cargo.lock | 22 +------------- ddprof-exporter/Cargo.toml | 2 +- ddprof-exporter/src/connector/conn_stream.rs | 30 ++++++++++++++++---- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/actions/cache/action.yaml b/.github/actions/cache/action.yaml index b5ae639..625d672 100644 --- a/.github/actions/cache/action.yaml +++ b/.github/actions/cache/action.yaml @@ -1,5 +1,5 @@ -name: '[rust] Checkout and cache' -description: '[rust] Checkout cache' +name: '[rust] Cache' +description: '[rust] Cache' runs: using: composite diff --git a/Cargo.lock b/Cargo.lock index decd95e..88af977 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,7 +133,7 @@ dependencies = [ "maplit", "mime_guess", "percent-encoding", - "pin-project", + "pin-project-lite", "regex", "rustls", "rustls-native-certs", @@ -572,26 +572,6 @@ dependencies = [ "indexmap", ] -[[package]] -name = "pin-project" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "pin-project-lite" version = "0.2.8" diff --git a/ddprof-exporter/Cargo.toml b/ddprof-exporter/Cargo.toml index eab130e..b915dd1 100644 --- a/ddprof-exporter/Cargo.toml +++ b/ddprof-exporter/Cargo.toml @@ -27,7 +27,7 @@ futures-core = { version = "0.3.0", default-features = false } futures-util = { version = "0.3.0", default-features = false } mime_guess = { version = "2.0", default-features = false } http-body = "0.4" -pin-project = "1.0" +pin-project-lite = "0.2.8" rustls = { version = "0.20.4", default-features = false } rustls-native-certs = { version = "0.6" } hyper-rustls = { version = "0.23", default-features = false, features = ["native-tokio", "http1", "tls12"] } diff --git a/ddprof-exporter/src/connector/conn_stream.rs b/ddprof-exporter/src/connector/conn_stream.rs index 579f010..ba6e8f4 100644 --- a/ddprof-exporter/src/connector/conn_stream.rs +++ b/ddprof-exporter/src/connector/conn_stream.rs @@ -8,17 +8,37 @@ use std::{ use futures::{future, Future, FutureExt, TryFutureExt}; use hyper_rustls::HttpsConnector; -use pin_project::pin_project; +use pin_project_lite::pin_project; +#[cfg(unix)] pin_project! { #[derive(Debug)] #[project = ConnStreamProj] pub enum ConnStream { - Tcp{ #[pin] transport: tokio::net::TcpStream }, - Tls{ #[pin] transport: tokio_rustls::client::TlsStream}, + Tcp { + #[pin] transport: tokio::net::TcpStream, + }, + Tls { + #[pin] transport: tokio_rustls::client::TlsStream, + }, // Tokio doesn't handle unix sockets on windows - #[cfg(unix)] - Udp{ #[pin] transport: tokio::net::UnixStream }, + Udp { + #[pin] transport: tokio::net::UnixStream, + }, + } +} + +#[cfg(not(unix))] +pin_project! { + #[derive(Debug)] + #[project = ConnStreamProj] + pub enum ConnStream { + Tcp { + #[pin] transport: tokio::net::TcpStream, + }, + Tls { + #[pin] transport: tokio_rustls::client::TlsStream, + }, } }