Struct tendermint_rpc::Subscription[][src]

pub struct Subscription { /* fields omitted */ }

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

Examples

use tendermint_rpc::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
        }
    }
}

Implementations

impl Subscription[src]

pub fn id(&self) -> &str[src]

Return this subscription’s ID for informational purposes.

pub fn query(&self) -> &Query[src]

Trait Implementations

impl Debug for Subscription[src]

impl Stream for Subscription[src]

type Item = Result<Event>

Values yielded by the stream.

impl<'pin> Unpin for Subscription where
    __Subscription<'pin>: Unpin
[src]

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, 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

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

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

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