Module client

Module client 

Source
Expand description

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

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.

Structs§

BackoffConfig
Configuration for exponential backoff retry behavior.
CommandRequest
A command request to execute a state change.
Connection
A connection to an EvidentSource database with live metadata updates.
CorrelationId
A correlation ID returned from async commands.
DatabaseMetadata
Metadata about the database state, updated via subscription.
DatabaseName
A validated database name.
DateTime
ISO 8601 combined date and time with time zone.
DevModeCredentials
DevMode credentials for local development and testing.
Event
A stored event with a full source URI.
EventQueryBuilder
Builder for constructing event queries with options.
EventSubject
A validated event subject.
EventType
A validated event type.
EvidentSource
The main entrypoint for connecting to an EvidentSource server.
EvidentSourceBuilder
Builder for configuring and connecting to an EvidentSource server.
NonEmpty
Non-empty vector.
ProspectiveEvent
A prospective event before storage.
StateChangeBuilder
Builder for executing state changes.
StateChangeName
A validated state change name.
StateView
A materialized state view.
StateViewName
A validated state view name.
StreamName
A validated stream name.
Transaction
A transaction of events that were committed together.
TransactionBuilder
Builder for constructing transactions.
TransactionSummary
Summary information about a committed transaction.
TypedEventQuery
A typed event query that converts events to a specific type.
Utc
The UTC time zone. This is the most efficient time zone when you don’t need the local time. It is also used as an offset (which is also a dummy type).

Enums§

AppendCondition
An append condition for a batch transaction (DCB spec: “Append Condition”).
Credentials
Credentials for authenticating with EvidentSource server.
DatabaseError
Errors related to database operations
EventAttribute
An event attribute for exact matching.
EventAttributePrefix
An event attribute prefix for starts-with matching.
EventData
Event data payload.
EventSelector
A selector for matching events.
StateChangeError
Errors related to state change operations
StateViewError
Errors related to state view operations
TlsConfig
TLS configuration for the connection.

Traits§

DatabaseAtRevisionTyped
Extension trait for typed state view access.
DatabaseConnectionAsync
Extension trait for async database operations.