rs-mongo-stream
A MongoDB change stream library for Rust applications
Overview
rs-mongo-stream is a Rust library that makes it easy to work with MongoDB change streams. It provides a simple interface to monitor and react to changes in your MongoDB collections by registering callbacks for different database events (insertions, updates, and deletions).
Features
- Event-based architecture: Register callbacks for insert, update, and delete operations
- Asynchronous support: Built with Tokio for fully asynchronous operation
- Automatic reconnection: Handles stream disruptions gracefully
- Implements Stream trait: Can be used with standard Rust stream operations
- Type-safe callbacks: Strong typing for your event handlers
Installation
Add the crate to your Cargo.toml:
[]
= "0.1.0"
= "2.4.0"
= { = "1", = ["full"] }
Usage Example
use ;
use ;
use tokio;
async
Error Handling
The library provides a custom MongoStreamError type that wraps errors from the MongoDB driver and adds context when needed.
License
This project is licensed under the MIT License - see the LICENSE file for details.