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.