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 serverConnection- A live connection to a specific database- Domain types from
evidentsource_core::domainfor 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§
- Backoff
Config - Configuration for exponential backoff retry behavior.
- Command
Request - A command request to execute a state change.
- Connection
- A connection to an EvidentSource database with live metadata updates.
- Correlation
Id - A correlation ID returned from async commands.
- Database
Metadata - Metadata about the database state, updated via subscription.
- Database
Name - A validated database name.
- Date
Time - ISO 8601 combined date and time with time zone.
- DevMode
Credentials - DevMode credentials for local development and testing.
- Event
- A stored event with a full source URI.
- Event
Query Builder - Builder for constructing event queries with options.
- Event
Subject - A validated event subject.
- Event
Type - A validated event type.
- Evident
Source - The main entrypoint for connecting to an EvidentSource server.
- Evident
Source Builder - Builder for configuring and connecting to an EvidentSource server.
- NonEmpty
- Non-empty vector.
- Prospective
Event - A prospective event before storage.
- State
Change Builder - Builder for executing state changes.
- State
Change Name - A validated state change name.
- State
View - A materialized state view.
- State
View Name - A validated state view name.
- Stream
Name - A validated stream name.
- Transaction
- A transaction of events that were committed together.
- Transaction
Builder - Builder for constructing transactions.
- Transaction
Summary - Summary information about a committed transaction.
- Typed
Event Query - 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§
- Append
Condition - An append condition for a batch transaction (DCB spec: “Append Condition”).
- Credentials
- Credentials for authenticating with EvidentSource server.
- Database
Error - Errors related to database operations
- Event
Attribute - An event attribute for exact matching.
- Event
Attribute Prefix - An event attribute prefix for starts-with matching.
- Event
Data - Event data payload.
- Event
Selector - A selector for matching events.
- State
Change Error - Errors related to state change operations
- State
View Error - Errors related to state view operations
- TlsConfig
- TLS configuration for the connection.
Traits§
- Database
AtRevision Typed - Extension trait for typed state view access.
- Database
Connection Async - Extension trait for async database operations.