Trait Driver

Source
pub trait Driver:
    Clone
    + Send
    + Sync
    + 'static {
    type Error: Error + Send + 'static;
    type EvStream: Stream<Item = Result<Item, Self::Error>> + Unpin + Send + 'static;

    // Required methods
    fn watch(
        &self,
        server_id: Uid,
        ns: &str,
    ) -> impl Future<Output = Result<Self::EvStream, Self::Error>> + Send;
    fn emit(
        &self,
        data: &Item,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
Expand description

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

Required Associated Types§

Source

type Error: Error + Send + 'static

The error type for the driver.

Source

type EvStream: Stream<Item = Result<Item, Self::Error>> + Unpin + Send + 'static

The event stream returned by the Driver::watch method.

Required Methods§

Source

fn watch( &self, server_id: Uid, ns: &str, ) -> impl Future<Output = Result<Self::EvStream, Self::Error>> + Send

Watch for document insertions on the collection. This should be implemented by change streams but could be implemented by anything else.

The implementation should take care of filtering the events. It must pass events that originate from our server and if the target is set it should pass events sent for us. Here is the corresponding filter: origin != self.uid && (target == null || target == self.uid).

Source

fn emit( &self, data: &Item, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Emit an document to the collection.

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 MongoDbDriver

Available on crate feature mongodb only.