diff options
author | Igor Matuszewski <igor@sequoia-pgp.org> | 2020-10-19 17:59:19 +0200 |
---|---|---|
committer | Igor Matuszewski <igor@sequoia-pgp.org> | 2020-10-23 12:05:54 +0200 |
commit | d30e05a43655a3884c6119e282e0ac58a9c723f7 (patch) | |
tree | eeff82e5a4d40b933a9bd7849396812013eacf39 /ipc/examples | |
parent | eb324f60bbd4184057797f72cc3db34e6160497d (diff) |
ipc: Migrate to std::futures
Diffstat (limited to 'ipc/examples')
-rw-r--r-- | ipc/examples/assuan-client.rs | 25 | ||||
-rw-r--r-- | ipc/examples/gpg-agent-client.rs | 25 |
2 files changed, 25 insertions, 25 deletions
diff --git a/ipc/examples/assuan-client.rs b/ipc/examples/assuan-client.rs index 6d790363..16c6ed41 100644 --- a/ipc/examples/assuan-client.rs +++ b/ipc/examples/assuan-client.rs @@ -1,6 +1,4 @@ -use futures; -use futures::future::Future; -use futures::stream::Stream; +use futures::StreamExt; use clap; use sequoia_ipc as ipc; use crate::ipc::assuan::Client; @@ -18,14 +16,15 @@ fn main() { .help("Commands to send to the server")) .get_matches(); - let mut c = Client::connect(matches.value_of("server").unwrap()) - .wait().unwrap(); - for command in matches.values_of("commands").unwrap() { - eprintln!("> {}", command); - c.send(command).unwrap(); - c.by_ref().for_each(|response| { - eprintln!("< {:?}", response); - Ok(()) - }).wait().unwrap(); - } + let mut rt = tokio::runtime::Runtime::new().unwrap(); + rt.block_on(async { + let mut c = Client::connect(matches.value_of("server").unwrap()).await.unwrap(); + for command in matches.values_of("commands").unwrap() { + eprintln!("> {}", command); + c.send(command).unwrap(); + while let Some(response) = c.next().await { + eprintln!("< {:?}", response); + } + } + }); } diff --git a/ipc/examples/gpg-agent-client.rs b/ipc/examples/gpg-agent-client.rs index 61a29e84..64b60234 100644 --- a/ipc/examples/gpg-agent-client.rs +++ b/ipc/examples/gpg-agent-client.rs @@ -1,8 +1,6 @@ /// Connects to and sends commands to gpg-agent. -use futures; -use futures::future::Future; -use futures::stream::Stream; +use futures::StreamExt; use clap; use sequoia_ipc as ipc; use crate::ipc::gnupg::{Context, Agent}; @@ -25,14 +23,17 @@ fn main() { } else { Context::new().unwrap() }; - let mut agent = Agent::connect(&ctx).wait().unwrap(); - for command in matches.values_of("commands").unwrap() { - eprintln!("> {}", command); - agent.send(command).unwrap(); - agent.by_ref().for_each(|response| { - eprintln!("< {:?}", response); - Ok(()) - }).wait().unwrap(); - } + let mut rt = tokio::runtime::Runtime::new().unwrap(); + rt.block_on(async { + let mut agent = Agent::connect(&ctx).await.unwrap(); + + for command in matches.values_of("commands").unwrap() { + eprintln!("> {}", command); + agent.send(command).unwrap(); + while let Some(response) = agent.next().await { + eprintln!("< {:?}", response); + } + } + }); } |