From c3a66c32cab41eadcc7d69c508c5efcee1da205c Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 5 Dec 2022 16:41:55 +0000 Subject: [PATCH] wip --- sdk/rust/nym-sdk/examples/complex_config.rs | 19 ++++++++++--------- sdk/rust/nym-sdk/examples/simple.rs | 6 +++--- sdk/rust/nym-sdk/src/mixnet/mod.rs | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/sdk/rust/nym-sdk/examples/complex_config.rs b/sdk/rust/nym-sdk/examples/complex_config.rs index 38b0086f54..c34038162e 100644 --- a/sdk/rust/nym-sdk/examples/complex_config.rs +++ b/sdk/rust/nym-sdk/examples/complex_config.rs @@ -1,16 +1,17 @@ +use std::path::PathBuf; + +use nym_sdk::mixnet; + #[tokio::main] async fn main() { // specify some config options - let config = mixnet::Config { - option: value, - option2: value2, - keyfiles: "~/.flappapapappa/keys/", - }; + let keys = Some(PathBuf::from("~/.nym/clients/superfoomp")); + let config = mixnet::Config { keys }; - let client = mixnet::Client::new(&config); // passing a config allows the user to set values + let client = mixnet::Client::new(Some(config)); // passing a config allows the user to set values - let show_receive = move || println!("got a message from the mixnet: {}", message); // might need to bury this in a struct as a `FnOnce`, see https://stackoverflow.com/questions/41081240/idiomatic-callbacks-in-rust - client.on_receive(show_receive); // have some way to pipe any received info to a function for processing + // let show_receive = move || println!("got a message from the mixnet: {}", message); // might need to bury this in a struct as a `FnOnce`, see https://stackoverflow.com/questions/41081240/idiomatic-callbacks-in-rust + // client.on_receive(show_receive); // have some way to pipe any received info to a function for processing // connect to the mixnet, now we're listening for incoming client.connect_to_mixnet(); @@ -19,5 +20,5 @@ async fn main() { println!("Our client address is {}", client.nym_address); // send important info up the pipe to a buddy - client.send("foo.bar@blah", "flappappa"); + client.send_str("foo.bar@blah", "flappappa"); } diff --git a/sdk/rust/nym-sdk/examples/simple.rs b/sdk/rust/nym-sdk/examples/simple.rs index d6a79889de..2ff8dae9c8 100644 --- a/sdk/rust/nym-sdk/examples/simple.rs +++ b/sdk/rust/nym-sdk/examples/simple.rs @@ -5,9 +5,7 @@ async fn main() { // here's what I'd actually like to write let client = mixnet::Client::new(None); // passing no config makes the client fire up an ephemeral session and figure shit out on its own - let show_receive = move || println!("got a message from the mixnet: {}", message); // might need to bury this in a struct as a `FnMut`, see https://stackoverflow.com/questions/41081240/idiomatic-callbacks-in-rust - client.on_receive(show_receive); // have some way to pipe any received info to a function for processing - + // let show_receive = move || println!("got a message from the mixnet: {}", message); // might need to bury this in a struct as a `FnMut`, see https://stackoverflow.com/questions/41081240/idiomatic-callbacks-in-rust // connect to the mixnet, now we're listening for incoming client.connect_to_mixnet(); @@ -19,4 +17,6 @@ async fn main() { // send some bytes to a buddy client.send_bytes("foo.bar@blah", "flappappa".as_bytes().to_vec()); + + } diff --git a/sdk/rust/nym-sdk/src/mixnet/mod.rs b/sdk/rust/nym-sdk/src/mixnet/mod.rs index c37c4f1995..46ea1aadde 100644 --- a/sdk/rust/nym-sdk/src/mixnet/mod.rs +++ b/sdk/rust/nym-sdk/src/mixnet/mod.rs @@ -58,5 +58,5 @@ impl Client { } pub struct Config { - keys: Option, + pub keys: Option, }