configure_transport.rs (962B)
1 use radroots_transport::{EventSink, EventSource, EventSubscriber}; 2 use radroots_transport_nostr::{ 3 Config, NostrTransport, RelayAccess, RelayEndpoint, RelayProfile, RelayProfileKind, 4 RelayUrlPolicy, 5 }; 6 7 fn main() -> Result<(), Box<dyn std::error::Error>> { 8 let endpoint = RelayEndpoint::new( 9 "wss://relay.example.com", 10 RelayUrlPolicy::Public, 11 RelayAccess::ReadWrite, 12 )?; 13 let profile = RelayProfile::explicit(RelayProfileKind::Public, [endpoint])?; 14 let config = Config::from_profile(profile).with_timeouts(5_000, 20_000, 2_000)?; 15 let transport = NostrTransport::new(config); 16 17 let source: &dyn EventSource = &transport; 18 let subscriber: &dyn EventSubscriber = &transport; 19 let sink: &dyn EventSink = &transport; 20 drop(source.status()); 21 let _ = subscriber; 22 drop(sink.status()); 23 24 println!("configured a Nostr source, subscriber, and sink without opening a relay connection"); 25 Ok(()) 26 }