Trait SubscriptionClient

Source
pub trait SubscriptionClient {
    // Required methods
    fn subscribe<'life0, 'async_trait>(
        &'life0 self,
        query: Query,
    ) -> Pin<Box<dyn Future<Output = Result<Subscription, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn unsubscribe<'life0, 'async_trait>(
        &'life0 self,
        query: Query,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn close(self) -> Result<(), Error>;
}
Expand description

A client that exclusively provides Event subscription capabilities, without any other RPC method support.

Required Methods§

Source

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

/subscribe: subscribe to receive events produced by the given query.

Source

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

/unsubscribe: unsubscribe from events relating to the given query.

This method is particularly useful when you want to terminate multiple Subscriptions to the same Query simultaneously, or if you’ve joined multiple Subscriptions together using select_all and you no longer have access to the individual Subscription instances to terminate them separately.

Source

fn close(self) -> Result<(), Error>

Subscription clients will usually have long-running underlying transports that will need to be closed at some point.

Implementors§