47 releases (8 stable)

3.0.0 Feb 29, 2024
2.3.0 Oct 17, 2023
2.2.0 Feb 13, 2023
2.1.2-alpha Jun 9, 2022
0.1.0 Jun 20, 2018

#165 in Database interfaces

Download history 402/week @ 2024-07-22 395/week @ 2024-07-29 196/week @ 2024-08-05 513/week @ 2024-08-12 732/week @ 2024-08-19 353/week @ 2024-08-26 323/week @ 2024-09-02 319/week @ 2024-09-09 300/week @ 2024-09-16 392/week @ 2024-09-23 328/week @ 2024-09-30 381/week @ 2024-10-07 457/week @ 2024-10-14 311/week @ 2024-10-21 461/week @ 2024-10-28 366/week @ 2024-11-04

1,602 downloads per month
Used in 3 crates

MIT license

480KB
11K SLoC

EventStoreDB Rust Client

Crates.io Crates.io Build Status Discord Crates.io

Documentation

Official Rust EventStoreDB rust gRPC gRPC Client.

EventStoreDB is an open-source database built from the ground up for Event Sourcing, with Complex Event Processing in Javascript.

EventStoreDB Server Compatibility

This client is compatible with version 20.6.1 upwards and works on Linux, MacOS and Windows.

Server setup instructions can be found here EventStoreDB Docs, follow the docker setup for the simplest configuration.

Example

use eventstore::{ Client, EventData };
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug)]
struct Foo {
    is_rust_a_nice_language: bool,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {

    // Creates a client settings for a single node configuration.
    let settings = "esdb://admin:changeit@localhost:2113".parse()?;
    let client = Client::new(settings)?;

    let payload = Foo {
        is_rust_a_nice_language: true,
    };

    // It is not mandatory to use JSON as a data format however EventStoreDB
    // provides great additional value if you do so.
    let evt = EventData::json("language-poll", &payload)?;

    client
        .append_to_stream("language-stream", &Default::default(), evt)
        .await?;

    let mut stream = client
        .read_stream("language-stream", &Default::default())
        .await?;

    while let Some(event) = stream.next().await? {
        let event = event.get_original_event()
          .as_json::<Foo>()?;

        // Do something productive with the result.
        println!("{:?}", event);
    }

    Ok(())
}

Support

Information on support can be found here: EventStoreDB Support

Documentation

Documentation for EventStoreDB can be found here: EventStoreDB Docs

Bear in mind that this client is not yet properly documented. We are working hard on a new version of the documentation.

Community

We have a community discussion space at EventStoreDB Discuss.

Dependencies

~21–35MB
~649K SLoC