Trait Driver

Source
pub trait Driver:
    Clone
    + Send
    + Sync
    + 'static {
    type Error: Error + Send + 'static;

    // Required methods
    fn publish(
        &self,
        chan: String,
        val: Vec<u8>,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn subscribe(
        &self,
        chan: String,
        size: usize,
    ) -> impl Future<Output = Result<MessageStream<ChanItem>, Self::Error>> + Send;
    fn unsubscribe(
        &self,
        pat: String,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn num_serv(
        &self,
        chan: &str,
    ) -> impl Future<Output = Result<u16, Self::Error>> + Send;
}
Expand description

The driver trait can be used to support different pub/sub backends. It must share handlers/connection between its clones.

Required Associated Types§

Source

type Error: Error + Send + 'static

The error type for the driver.

Required Methods§

Source

fn publish( &self, chan: String, val: Vec<u8>, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Publish a message to a channel.

Source

fn subscribe( &self, chan: String, size: usize, ) -> impl Future<Output = Result<MessageStream<ChanItem>, Self::Error>> + Send

Subscribe to a channel, it will return a stream of messages. The size parameter is the buffer size of the channel.

Source

fn unsubscribe( &self, pat: String, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Unsubscribe from a channel.

Source

fn num_serv( &self, chan: &str, ) -> impl Future<Output = Result<u16, Self::Error>> + Send

Returns the number of socket.io servers.

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§

Source§

impl Driver for FredDriver

Available on crate feature fred only.
Source§

impl Driver for ClusterDriver

Available on crate features redis and redis-cluster only.
Source§

impl Driver for RedisDriver

Available on crate feature redis only.