From dd03b0edb4928894b64b85cc44a4984a721650c2 Mon Sep 17 00:00:00 2001 From: Ferris Tseng Date: Tue, 23 Feb 2021 23:44:34 -0500 Subject: fixing actix examples by upgrading to new rt --- ipfs-api-backend-actix/Cargo.toml | 6 +++--- ipfs-api-backend-actix/src/backend.rs | 13 +++---------- ipfs-api-backend-hyper/Cargo.toml | 2 +- ipfs-api-examples/Cargo.toml | 2 +- ipfs-api-prelude/Cargo.toml | 4 ++-- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/ipfs-api-backend-actix/Cargo.toml b/ipfs-api-backend-actix/Cargo.toml index 22e4ba9..a0760d8 100644 --- a/ipfs-api-backend-actix/Cargo.toml +++ b/ipfs-api-backend-actix/Cargo.toml @@ -12,9 +12,9 @@ readme = "../README.md" license = "MIT OR Apache-2.0" [dependencies] -actix-http = "2.2" -actix-multipart-rfc7578 = "0.4" -awc = "2.0" +actix-http = "3.0.0-beta.2" +actix-multipart-rfc7578 = { version = "0.5", git = "https://github.com/ferristseng/rust-multipart-rfc7578", branch = "ftseng/upgrade-actix-rt" } +awc = "3.0.0-beta.2" async-trait = "0.1" bytes = "1.0" futures = "0.3" diff --git a/ipfs-api-backend-actix/src/backend.rs b/ipfs-api-backend-actix/src/backend.rs index 73fdf0b..fbbc6a4 100644 --- a/ipfs-api-backend-actix/src/backend.rs +++ b/ipfs-api-backend-actix/src/backend.rs @@ -86,15 +86,13 @@ impl Backend for ActixBackend { let body = res.body().await?; // FIXME: Actix compat with bytes 1.0 - Ok((status, Bytes::copy_from_slice(body.as_ref()))) + Ok((status, body)) } fn response_to_byte_stream( res: Self::HttpResponse, ) -> Box> + Unpin> { - let stream = res - .map_ok(|bytes| Bytes::copy_from_slice(bytes.as_ref())) - .err_into(); + let stream = res.err_into(); Box::new(stream) } @@ -120,12 +118,7 @@ impl Backend for ActixBackend { _ => res .body() .map(|maybe_body| match maybe_body { - Ok(body) => { - // FIXME: Actix compat with bytes 1.0 - let body = Bytes::copy_from_slice(body.as_ref()); - - Err(Self::process_error_from_body(body)) - } + Ok(body) => Err(Self::process_error_from_body(body)), Err(e) => Err(e.into()), }) .into_stream() diff --git a/ipfs-api-backend-hyper/Cargo.toml b/ipfs-api-backend-hyper/Cargo.toml index 03ee234..d45e069 100644 --- a/ipfs-api-backend-hyper/Cargo.toml +++ b/ipfs-api-backend-hyper/Cargo.toml @@ -17,7 +17,7 @@ bytes = "1.0" futures = "0.3" http = "0.2" hyper = { version = "0.14", features = ["http1", "http2", "client"] } -hyper-multipart-rfc7578 = "0.5" +hyper-multipart-rfc7578 = { version = "0.5", git = "https://github.com/ferristseng/rust-multipart-rfc7578", branch = "ftseng/upgrade-actix-rt" } hyper-tls = "0.5" ipfs-api-prelude = { version = "0.1.0", path = "../ipfs-api-prelude" } serde = "1.0" diff --git a/ipfs-api-examples/Cargo.toml b/ipfs-api-examples/Cargo.toml index 531dc53..d8c117e 100644 --- a/ipfs-api-examples/Cargo.toml +++ b/ipfs-api-examples/Cargo.toml @@ -17,7 +17,7 @@ with-hyper = ["ipfs-api-backend-hyper", "tokio-hyper", "tokio-hyp with-actix = ["ipfs-api-backend-actix", "tokio-actix", "actix-rt"] [dependencies] -actix-rt = { version = "1.1", optional = true } +actix-rt = { version = "2.0", optional = true } futures = "0.3" ipfs-api-backend-actix = { version = "0.1", path = "../ipfs-api-backend-actix", optional = true } ipfs-api-backend-hyper = { version = "0.1", path = "../ipfs-api-backend-hyper", optional = true } diff --git a/ipfs-api-prelude/Cargo.toml b/ipfs-api-prelude/Cargo.toml index 21f9088..ed2c03b 100644 --- a/ipfs-api-prelude/Cargo.toml +++ b/ipfs-api-prelude/Cargo.toml @@ -17,7 +17,7 @@ with-builder = ["typed-builder"] [dependencies] async-trait = "0.1" bytes = "1.0" -common-multipart-rfc7578 = "0.3.0" +common-multipart-rfc7578 = { version = "0.3", git = "https://github.com/ferristseng/rust-multipart-rfc7578", branch = "ftseng/upgrade-actix-rt" } dirs = "3.0" futures = "0.3" http = "0.2" @@ -26,7 +26,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_urlencoded = "0.7" thiserror = "1.0" -tokio = "1.2" +tokio = "1" tokio-util = { version = "0.6", features = ["codec"] } tracing = "0.1" typed-builder = { version = "0.9", optional = true } -- cgit v1.2.3