summaryrefslogtreecommitdiffstats
path: root/ipc/examples
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/examples')
-rw-r--r--ipc/examples/assuan-client.rs25
-rw-r--r--ipc/examples/gpg-agent-client.rs25
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);
+ }
+ }
+ });
}