[][src]Struct tendermint_rpc::Subscription

pub struct Subscription {
    pub query: Query,
    pub id: SubscriptionId,
    // some fields omitted
}

An interface that can be used to asynchronously receive Events for a particular subscription.

Examples

use tendermint_rpc::{SubscriptionId, Subscription};
use futures::StreamExt;

/// Prints `count` events from the given subscription.
async fn print_events(subs: &mut Subscription, count: usize) {
    let mut counter = 0_usize;
    while let Some(res) = subs.next().await {
        // Technically, a subscription produces `Result<Event, Error>`
        // instances. Errors can be produced by the remote endpoint at any
        // time and need to be handled here.
        let ev = res.unwrap();
        println!("Got incoming event: {:?}", ev);
        counter += 1;
        if counter >= count {
            break
        }
    }
}

Fields

query: Query

The query for which events will be produced.

id: SubscriptionId

The ID of this subscription (automatically assigned).

Implementations

impl Subscription[src]

pub async fn terminate(__arg0: Self) -> Result<()>[src]

Gracefully terminate this subscription and consume it.

The Subscription can be moved to any asynchronous context, and this method provides a way to terminate it from that same context.

Trait Implementations

impl Debug for Subscription[src]

impl Stream for Subscription[src]

type Item = Result<Event>

Values yielded by the stream.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<St> StreamExt for St where
    St: Stream + ?Sized
[src]

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,