From 57a9e97dcab66c9f13331280335841b3d098b0b5 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 11 Nov 2021 03:20:55 -0500 Subject: switch to futures-lite --- Cargo.lock | 87 +--------------------------------------------------------- Cargo.toml | 2 +- src/history.rs | 14 ++++++---- 3 files changed, 11 insertions(+), 92 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9fcec96..1dc79fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -242,21 +242,6 @@ dependencies = [ "instant", ] -[[package]] -name = "futures" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - [[package]] name = "futures-channel" version = "0.3.17" @@ -264,7 +249,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" dependencies = [ "futures-core", - "futures-sink", ] [[package]] @@ -273,17 +257,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" -[[package]] -name = "futures-executor" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - [[package]] name = "futures-io" version = "0.3.17" @@ -305,52 +278,6 @@ dependencies = [ "waker-fn", ] -[[package]] -name = "futures-macro" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" -dependencies = [ - "autocfg", - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" - -[[package]] -name = "futures-task" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" - -[[package]] -name = "futures-util" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" -dependencies = [ - "autocfg", - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "slab", -] - [[package]] name = "gloo-timers" version = "0.2.1" @@ -450,7 +377,7 @@ dependencies = [ "anyhow", "async-process", "async-std", - "futures", + "futures-lite", "libc", "nix", "pty-process", @@ -518,18 +445,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - [[package]] name = "proc-macro2" version = "1.0.32" diff --git a/Cargo.toml b/Cargo.toml index dfb8dc4..9971030 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" anyhow = "1.0.45" async-process = "1.3.0" async-std = "1.10.0" -futures = "0.3.17" +futures-lite = "1.12.0" libc = "0.2.107" nix = "0.23.0" pty-process = { version = "0.1.1", features = ["backend-async-std"] } diff --git a/src/history.rs b/src/history.rs index 3586a3c..50e5ca7 100644 --- a/src/history.rs +++ b/src/history.rs @@ -34,12 +34,16 @@ impl History { let task_action = self.action.clone(); async_std::task::spawn(async move { loop { + enum Res { + Read(Result), + Write(Result, async_std::channel::RecvError>), + } let mut buf = [0_u8; 4096]; let mut pty = child.pty(); - let read = pty.read(&mut buf); - let write = input_r.recv(); - match futures::future::select(read, write).await { - futures::future::Either::Left((res, _)) => { + let read = async { Res::Read(pty.read(&mut buf).await) }; + let write = async { Res::Write(input_r.recv().await) }; + match futures_lite::future::race(read, write).await { + Res::Read(res) => { match res { Ok(bytes) => { task_entry @@ -67,7 +71,7 @@ impl History { .await .unwrap(); } - futures::future::Either::Right((res, _)) => match res { + Res::Write(res) => match res { Ok(bytes) => { pty.write(&bytes).await.unwrap(); } -- cgit v1.2.3-54-g00ecf