diff rust/chg/src/uihandler.rs @ 44737:e9e44e61042b

rust-chg: upgrade to futures-0.3 based libraries And do some trivial fixes: - BytesMut::put_u32_be() -> put_u32() - tokio_process -> tokio::process, CommandExt -> Command, spawn_async() -> spawn(), stdin() -> stdin - tokio_timer::sleep() -> tokio::time::delay_for() Differential Revision: https://phab.mercurial-scm.org/D8441
author Yuya Nishihara <yuya@tcha.org>
date Fri, 10 Apr 2020 21:54:03 +0900
parents 6bef9d43cc55
children c794d0da5fb2
line wrap: on
line diff
--- a/rust/chg/src/uihandler.rs	Fri Apr 10 21:44:46 2020 +0900
+++ b/rust/chg/src/uihandler.rs	Fri Apr 10 21:54:03 2020 +0900
@@ -8,9 +8,9 @@
 use std::io;
 use std::os::unix::io::AsRawFd;
 use std::os::unix::process::ExitStatusExt;
-use std::process::{Command, Stdio};
+use std::process::Stdio;
 use tokio;
-use tokio_process::{ChildStdin, CommandExt};
+use tokio::process::{ChildStdin, Command};
 
 use crate::message::CommandSpec;
 use crate::procutil;
@@ -47,10 +47,8 @@
     type RunSystemResult = Box<dyn Future<Item = (Self, i32), Error = io::Error> + Send>;
 
     fn spawn_pager(self, spec: CommandSpec) -> Self::SpawnPagerResult {
-        let mut pager = new_shell_command(&spec)
-            .stdin(Stdio::piped())
-            .spawn_async()?;
-        let pin = pager.stdin().take().unwrap();
+        let mut pager = new_shell_command(&spec).stdin(Stdio::piped()).spawn()?;
+        let pin = pager.stdin.take().unwrap();
         procutil::set_blocking_fd(pin.as_raw_fd())?;
         // TODO: if pager exits, notify the server with SIGPIPE immediately.
         // otherwise the server won't get SIGPIPE if it does not write
@@ -62,7 +60,7 @@
 
     fn run_system(self, spec: CommandSpec) -> Self::RunSystemResult {
         let fut = new_shell_command(&spec)
-            .spawn_async()
+            .spawn()
             .into_future()
             .flatten()
             .map(|status| {