From 2f347ee0d6bcd6650664b8d1567e144d6efc79d5 Mon Sep 17 00:00:00 2001 From: glyph Date: Wed, 13 Jul 2022 11:08:45 +0100 Subject: [PATCH] accept String or &str for ip_port and net_id --- src/sbot.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/sbot.rs b/src/sbot.rs index 63bdeb4..4e28967 100644 --- a/src/sbot.rs +++ b/src/sbot.rs @@ -53,15 +53,19 @@ impl Sbot { /// Initiate a connection with an sbot instance. Define the IP address, /// port and network key for the sbot, then retrieve the public key, /// private key (secret) and identity from the `.ssb-go/secret` file. - pub async fn init( + pub async fn init( keystore: Keystore, - ip_port: Option, - net_id: Option, - ) -> Result { + ip_port: Option, + net_id: Option, + ) -> Result + where + S: Into, + T: Into, + { let mut address = if ip_port.is_none() { "127.0.0.1:8008".to_string() } else { - ip_port.unwrap() + ip_port.unwrap().into() }; if address.starts_with(':') { @@ -71,7 +75,7 @@ impl Sbot { let network_id = if net_id.is_none() { discovery::ssb_net_id() } else { - auth::Key::from_slice(&hex::decode(net_id.unwrap()).unwrap()).unwrap() + auth::Key::from_slice(&hex::decode(net_id.unwrap().into()).unwrap()).unwrap() }; let OwnedIdentity { pk, sk, id } = match keystore {