accept String or &str for ip_port and net_id
This commit is contained in:
parent
22d12f31ac
commit
2f347ee0d6
16
src/sbot.rs
16
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<S, T>(
|
||||
keystore: Keystore,
|
||||
ip_port: Option<String>,
|
||||
net_id: Option<String>,
|
||||
) -> Result<Sbot, GolgiError> {
|
||||
ip_port: Option<S>,
|
||||
net_id: Option<T>,
|
||||
) -> Result<Sbot, GolgiError>
|
||||
where
|
||||
S: Into<String>,
|
||||
T: Into<String>,
|
||||
{
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue