1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! Official Rust [EventStoreDB] 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
//!
//! ```no_run
//! 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)?;
//!
//!     let _ = 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(())
//! }
//! ```
//! [EventStoreDB]: https://eventstore.com/
//! [eventstoredb docs]: https://developers.eventstore.com/server/20.6/server/installation/
#[macro_use]
extern crate log;

mod batch;
mod client;
mod commands;
mod event_store;
mod grpc;
mod http;
pub mod operations;
mod options;
mod private;
mod projection_client;
mod server_features;
mod types;

pub(crate) mod google {
    pub mod rpc {
        pub use super::super::event_store::generated::google_rpc::*;
    }
}

pub use batch::*;
pub use client::Client;
pub use commands::{PersistentSubscription, ReadStream, Subscription};
pub use grpc::{ClientSettings, ClientSettingsParseError};
pub use options::append_to_stream::*;
pub use options::batch_append::*;
pub use options::delete_stream::*;
pub use options::persistent_subscription::*;
pub use options::projections::*;
pub use options::read_all::*;
pub use options::read_stream::*;
pub use options::retry::*;
pub use options::subscribe_to_all::*;
pub use options::subscribe_to_stream::*;
pub use options::tombstone_stream::*;
pub use projection_client::*;
pub use types::*;

pub mod prelude {
    pub use crate::batch::*;
    pub use crate::client::Client;
    pub use crate::commands::{PersistentSubscription, ReadStream, Subscription};
    pub use crate::grpc::{ClientSettings, ClientSettingsParseError};
    pub use crate::options::append_to_stream::*;
    pub use crate::options::batch_append::*;
    pub use crate::options::delete_stream::*;
    pub use crate::options::persistent_subscription::*;
    pub use crate::options::projections::*;
    pub use crate::options::read_all::*;
    pub use crate::options::read_stream::*;
    pub use crate::options::retry::*;
    pub use crate::options::subscribe_to_all::*;
    pub use crate::options::subscribe_to_stream::*;
    pub use crate::options::tombstone_stream::*;
    pub use crate::projection_client::*;
    pub use crate::types::*;
}