I mean Rust.
Discussion
Async makes Rust less fun and is overkill for small stuff
I'm happy with the Kotlin bindings as they are.
Ahh ok. I'll think about that. But it's pretty easy to write a blocking wrapper, including only the stuff you need. This could be a solution for your above request:
```toml
[dependencies]
nostr-sdk = "0.36"
tokio = { version = "1.41", features = ["full"] }
```
```rust
use std::sync::LazyLock;
use nostr_sdk::prelude::*;
use tokio::runtime::Runtime;
static RUNTIME: LazyLock
pub struct ClientBlocking {
inner: Client,
}
impl ClientBlocking {
pub fn add_relay(&self, url: &str) -> Result
RUNTIME.block_on(async {
Ok(self.inner.add_relay(url).await?)
})
}
pub fn connect(&self) {
RUNTIME.block_on(async {
self.inner.connect().await
})
}
pub fn send_event(&self, event: Event) -> Result
RUNTIME.block_on(async {
Ok(self.inner.send_event(event).await?)
})
}
pub fn subscribe(&self, filters: Vec
RUNTIME.block_on(async {
Ok(self.inner.subscribe(filters, None).await?)
})
}
pub fn handle_notifications
where
F: Fn(RelayPoolNotification) -> Result
{
let mut notifications = self.inner.notifications();
while let Ok(notification) = RUNTIME.block_on(notifications.recv()) {
let shutdown: bool = RelayPoolNotification::Shutdown == notification;
let exit: bool = func(notification)?;
if exit || shutdown {
break;
}
}
Ok(())
}
}
```