Skip to main content

RelayPoolTrait

Trait RelayPoolTrait 

Source
pub trait RelayPoolTrait: Send + Sync {
    // Required methods
    fn connect<'life0, 'life1, 'async_trait>(
        &'life0 self,
        relay_urls: &'life1 [String],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn disconnect<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn publish_event<'life0, 'life1, 'async_trait>(
        &'life0 self,
        event: &'life1 Event,
    ) -> Pin<Box<dyn Future<Output = Result<EventId>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn publish<'life0, 'async_trait>(
        &'life0 self,
        builder: EventBuilder,
    ) -> Pin<Box<dyn Future<Output = Result<EventId>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn sign<'life0, 'async_trait>(
        &'life0 self,
        builder: EventBuilder,
    ) -> Pin<Box<dyn Future<Output = Result<Event>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn signer<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn NostrSigner>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn notifications(&self) -> Receiver<RelayPoolNotification>;
    fn public_key<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<PublicKey>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn subscribe<'life0, 'async_trait>(
        &'life0 self,
        filters: Vec<Filter>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait abstracting relay pool operations, enabling dependency injection and testing.

Required Methods§

Source

fn connect<'life0, 'life1, 'async_trait>( &'life0 self, relay_urls: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Connect to the given relay URLs.

Source

fn disconnect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Disconnect from all relays.

Source

fn publish_event<'life0, 'life1, 'async_trait>( &'life0 self, event: &'life1 Event, ) -> Pin<Box<dyn Future<Output = Result<EventId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Publish a pre-built event to relays.

Source

fn publish<'life0, 'async_trait>( &'life0 self, builder: EventBuilder, ) -> Pin<Box<dyn Future<Output = Result<EventId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Build, sign, and publish an event from a builder.

Source

fn sign<'life0, 'async_trait>( &'life0 self, builder: EventBuilder, ) -> Pin<Box<dyn Future<Output = Result<Event>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sign an event builder without publishing.

Source

fn signer<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn NostrSigner>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the signer associated with this relay pool.

Source

fn notifications(&self) -> Receiver<RelayPoolNotification>

Get notifications receiver for event streaming.

Source

fn public_key<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<PublicKey>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the public key of the signer.

Source

fn subscribe<'life0, 'async_trait>( &'life0 self, filters: Vec<Filter>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to events matching filters.

Implementors§