From 0cf9751d7fc4bfe6c6fca8a29c4dc5d9a2a0bf53 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 23 Feb 2022 12:02:10 +0000 Subject: [PATCH] arti-hyper: Move hyper example from arti-client Code motion and consequential dependency adjustments. --- Cargo.lock | 6 +++++- crates/arti-client/Cargo.toml | 1 - crates/arti-hyper/Cargo.toml | 9 +++++++-- crates/{arti-client => arti-hyper}/examples/hyper.rs | 3 +-- 4 files changed, 13 insertions(+), 6 deletions(-) rename crates/{arti-client => arti-hyper}/examples/hyper.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index 758b6168a..7543c376e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -126,7 +126,6 @@ dependencies = [ "directories", "futures", "humantime-serde", - "hyper", "once_cell", "pin-project", "postage", @@ -168,8 +167,13 @@ dependencies = [ name = "arti-hyper" version = "0.0.4" dependencies = [ + "anyhow", "arti-client", "hyper", + "pin-project", + "tokio", + "tor-rtcompat", + "tracing-subscriber", ] [[package]] diff --git a/crates/arti-client/Cargo.toml b/crates/arti-client/Cargo.toml index 960bed077..757fcf3e2 100644 --- a/crates/arti-client/Cargo.toml +++ b/crates/arti-client/Cargo.toml @@ -48,7 +48,6 @@ thiserror = "1" [dev-dependencies] tor-rtcompat = { path="../tor-rtcompat", version = "0.0.4", features=["tokio", "native-tls" ] } tokio-crate = { package = "tokio", version = "1.4", features = ["rt", "rt-multi-thread", "io-util", "net", "time", "macros" ] } -hyper = { version = "0.14", features = ["http1", "client", "runtime"] } pin-project = "1" tokio-util = { version = "0.6", features = ["compat"] } anyhow = "1.0.23" diff --git a/crates/arti-hyper/Cargo.toml b/crates/arti-hyper/Cargo.toml index 1a563117c..82e2ec999 100644 --- a/crates/arti-hyper/Cargo.toml +++ b/crates/arti-hyper/Cargo.toml @@ -12,8 +12,8 @@ repository="https://gitlab.torproject.org/tpo/core/arti.git/" [features] default = [ "native-tls" ] -native-tls = [ "arti-client/native-tls" ] -rustls = [ "arti-client/rustls" ] +native-tls = [ "arti-client/native-tls", "tor-rtcompat/native-tls" ] +rustls = [ "arti-client/rustls", "tor-rtcompat/rustls" ] static = [ "arti-client/static" ] # Enable experimental APIs that are not yet officially supported. @@ -25,5 +25,10 @@ experimental-api = [] [dependencies] arti-client = { path="../arti-client", version = "0.0.4"} hyper = { version = "0.14", features = ["http1", "client", "runtime"] } +pin-project = "1" +tokio = { package = "tokio", version = "1.4", features = ["rt", "rt-multi-thread", "io-util", "net", "time", "macros" ] } +tor-rtcompat = { path="../tor-rtcompat", version = "0.0.4", features=["tokio"] } [dev-dependencies] +anyhow = "1.0.23" +tracing-subscriber = "0.3.0" diff --git a/crates/arti-client/examples/hyper.rs b/crates/arti-hyper/examples/hyper.rs similarity index 98% rename from crates/arti-client/examples/hyper.rs rename to crates/arti-hyper/examples/hyper.rs index efde2c172..dad4031af 100644 --- a/crates/arti-client/examples/hyper.rs +++ b/crates/arti-hyper/examples/hyper.rs @@ -12,7 +12,6 @@ use std::io::Error; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; -use tokio_crate as tokio; use tor_rtcompat::tokio::TokioNativeTlsRuntime; use tor_rtcompat::Runtime; @@ -138,7 +137,7 @@ async fn main() -> Result<()> { // on Linux platforms) let config = TorClientConfig::default(); // Arti needs an async runtime handle to spawn async tasks. - let rt: TokioNativeTlsRuntime = tokio_crate::runtime::Handle::current().into(); + let rt: TokioNativeTlsRuntime = tokio::runtime::Handle::current().into(); // We now let the Arti client start and bootstrap a connection to the network. // (This takes a while to gather the necessary consensus state, etc.)