Trait PubsubTransport

Source
pub trait PubsubTransport: Transport {
    type NotificationStream: Stream<Item = SubscriptionNotification>;

    // Required methods
    fn subscribe<'life0, 'async_trait, M>(
        &'life0 self,
        subscribe_method: M,
        params: Option<Params>,
    ) -> Pin<Box<dyn Future<Output = Result<(Id, Self::NotificationStream), Self::Error>> + Send + 'async_trait>>
       where M: Into<String> + Send + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn unsubscribe<'life0, 'async_trait, M>(
        &'life0 self,
        unsubscribe_method: M,
        subscription_id: Id,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
       where M: Into<String> + Send + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A JSON-RPC 2.0 transport supporting subscriptions.

Required Associated Types§

Source

type NotificationStream: Stream<Item = SubscriptionNotification>

The subscription stream.

Required Methods§

Source

fn subscribe<'life0, 'async_trait, M>( &'life0 self, subscribe_method: M, params: Option<Params>, ) -> Pin<Box<dyn Future<Output = Result<(Id, Self::NotificationStream), Self::Error>> + Send + 'async_trait>>
where M: Into<String> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Add a subscription to this transport.

Will send unsubscribe request to the server when drop the notification stream.

Source

fn unsubscribe<'life0, 'async_trait, M>( &'life0 self, unsubscribe_method: M, subscription_id: Id, ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
where M: Into<String> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Send an unsubscribe request to the server manually.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§