pub trait PubSub<T> {
    type Stream: Stream<Item = PublishMsg<T>> + Send;

    // Required method
    fn subscribe(&self, params: Params) -> Result<Self::Stream, Error>;
}
Available on crate feature server only.
Expand description

Implement this trait to define actual pub/sub logic.

Streams

Stream wrappers from tokio-stream can be used, e.g. BroadcastStream.

Or use the async-stream crate to implement streams with async-await. See the example server.

Required Associated Types§

source

type Stream: Stream<Item = PublishMsg<T>> + Send

Required Methods§

source

fn subscribe(&self, params: Params) -> Result<Self::Stream, Error>

Implementations on Foreign Types§

source§

impl<T, P: PubSub<T>> PubSub<T> for Arc<P>

§

type Stream = <P as PubSub<T>>::Stream

source§

fn subscribe(&self, params: Params) -> Result<Self::Stream, Error>

Implementors§

source§

impl<T, F, S> PubSub<T> for Fwhere F: Fn(Params) -> Result<S, Error>, S: Stream<Item = PublishMsg<T>> + Send,

§

type Stream = S