evidentsource-client 1.0.0-rc1

Rust client for the EvidentSource event sourcing platform
Documentation
//! High-level client API using domain types.
//!
//! This module provides an ergonomic, type-safe API for interacting with
//! EvidentSource using domain types from `evidentsource_core::domain`.
//!
//! # Overview
//!
//! The high-level API is organized around these main types:
//!
//! - [`EvidentSource`] - The main entrypoint for connecting to a server
//! - [`Connection`] - A live connection to a specific database
//! - Domain types from `evidentsource_core::domain` for events, conditions, etc.
//!
//! # Example
//!
//! ```rust,ignore
//! use evidentsource_client::client::{EvidentSource, Connection};
//! use evidentsource_core::domain::{DatabaseName, ProspectiveEvent, AppendCondition};
//!
//! // Connect to the server
//! let es = EvidentSource::connect_to_server("http://localhost:50051").await?;
//!
//! // List all databases
//! use futures::StreamExt;
//! let mut databases = es.list_databases();
//! while let Some(name) = databases.next().await {
//!     println!("Database: {}", name);
//! }
//!
//! // Connect to a specific database
//! let db_name = DatabaseName::new("my-db")?;
//! let conn = es.connect(&db_name).await?;
//!
//! // Get the latest database state
//! let db = conn.latest_database().await?;
//! println!("Current revision: {}", db.revision());
//!
//! // Query state views
//! let summary = db.view_state(&StateViewName::new("account-summary")?, 1).await?;
//! ```
//!
//! # When to use this module
//!
//! This is the recommended API for most applications. It provides:
//!
//! - Type-safe domain types that prevent common errors
//! - Automatic conversion between protocol buffers and domain types
//! - An ergonomic, Rust-idiomatic interface
//!
//! # Low-level access
//!
//! If you need direct access to the gRPC protocol for advanced use cases,
//! see the [`crate::grpc`] module.

// Re-export the main entrypoint
pub use crate::evident_source::{BackoffConfig, EvidentSource, EvidentSourceBuilder, TlsConfig};

// Re-export authentication types
pub use crate::auth::{Credentials, DevModeCredentials};

// Re-export connection types
pub use crate::connection::{
    Connection, CorrelationId, DatabaseConnectionAsync, DatabaseMetadata, StateChangeBuilder,
    TransactionBuilder,
};

// Re-export database types (traits and builders only - impl types are internal)
pub use crate::database::{DatabaseAtRevisionTyped, EventQueryBuilder, TypedEventQuery};

// Re-export domain types for convenience
pub use evidentsource_core::domain::{
    // Append conditions (DCB spec) and selectors
    AppendCondition,
    CommandRequest,
    // Errors
    DatabaseError,
    // Identifiers
    DatabaseName,
    // Events
    Event,
    EventAttribute,
    EventAttributePrefix,
    EventData,
    EventSelector,
    EventSubject,
    EventType,
    ProspectiveEvent,
    StateChangeError,
    StateChangeName,
    StateView,
    StateViewError,
    StateViewName,
    StreamName,
    // Transaction types
    Transaction,
    TransactionSummary,
};

// Re-export commonly used external types
pub use chrono::{DateTime, Utc};
pub use nonempty::NonEmpty;

// Re-export CloudEvents SDK conversion functions (feature-gated)
#[cfg(feature = "cloudevents")]
pub use crate::conversions::events::{
    cloudevent_to_event, cloudevent_to_prospective_event, event_to_cloudevent,
    prospective_event_to_cloudevent,
};