EvidentSource

Struct EvidentSource 

Source
pub struct EvidentSource { /* private fields */ }
Expand description

The main entrypoint for connecting to an EvidentSource server.

EvidentSource manages the gRPC connection and provides methods for:

  • Listing available databases (DatabaseCatalog trait)
  • Creating and deleting databases
  • Connecting to a specific database for operations

§Example

use evidentsource_client::EvidentSource;
use evidentsource_core::domain::DatabaseName;

// Connect to the server
let es = EvidentSource::connect_to_server("http://localhost:50051").await?;

// List all databases
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?;

// Use the connection for operations
let latest = conn.latest_database().await?;
println!("Latest revision: {}", latest.revision());

Implementations§

Source§

impl EvidentSource

Source

pub fn builder(addr: &str) -> EvidentSourceBuilder

Create a builder for configuring and connecting to an EvidentSource server.

§Example
use evidentsource_client::EvidentSource;
use std::time::Duration;

let es = EvidentSource::builder("http://localhost:50051")
    .connect_timeout(Duration::from_secs(10))
    .connect()
    .await?;
Source

pub async fn connect_to_server(addr: &str) -> Result<Self, Error>

Connect to an EvidentSource server without authentication.

This only works if the server has allow_anonymous=true.

§Arguments
  • addr - The server address (e.g., http://localhost:50051 or https://api.example.com)
§Example
let es = EvidentSource::connect_to_server("http://localhost:50051").await?;
Source

pub async fn connect_with_auth( addr: &str, credentials: Credentials, ) -> Result<Self, Error>

Connect to an EvidentSource server with authentication credentials.

§Arguments
  • addr - The server address (e.g., http://localhost:50051 or https://api.example.com)
  • credentials - Authentication credentials (BearerToken, DevMode, or None)
§Examples
use evidentsource_client::{EvidentSource, Credentials, DevModeCredentials};

// With bearer token (production - requires TLS)
let es = EvidentSource::connect_with_auth(
    "https://api.example.com:50051",
    Credentials::BearerToken(my_jwt_token),
).await?;

// With DevMode credentials (local development)
let es = EvidentSource::connect_with_auth(
    "http://localhost:50051",
    Credentials::DevMode(
        DevModeCredentials::new("dev-user@example.com")
            .with_email("dev@example.com")
            .with_display_name("Developer")
    ),
).await?;
Source

pub fn from_client(client: EvidentSourceClient) -> Self

Create an EvidentSource instance from an existing client.

Source

pub async fn connect( &self, database: &DatabaseName, ) -> Result<Connection, DatabaseError>

Connect to a specific database.

This returns a Connection that maintains a live subscription to database updates and implements DatabaseProvider and DatabaseConnection.

§Arguments
  • database - The name of the database to connect to
§Example
let db_name = DatabaseName::new("my-db")?;
let conn = es.connect(&db_name).await?;
Source

pub fn client(&self) -> &EvidentSourceClient

Get a reference to the underlying gRPC client.

This provides access to low-level operations not exposed through the high-level API.

Source

pub fn client_mut(&mut self) -> &mut EvidentSourceClient

Get a mutable reference to the underlying gRPC client.

Trait Implementations§

Source§

impl Clone for EvidentSource

Source§

fn clone(&self) -> EvidentSource

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DatabaseCatalog for EvidentSource

Source§

type Identity = DatabaseIdentityImpl

The type returned when creating a database.
Source§

fn list_databases(&self) -> impl Stream<Item = DatabaseName>

List all databases in the catalog.
Source§

fn create_database( &self, name: DatabaseName, ) -> impl Future<Output = Result<Self::Identity, DatabaseError>>

Create a new database with the given name.
Source§

fn delete_database( &self, name: DatabaseName, ) -> impl Future<Output = Result<(), DatabaseError>>

Delete a database by name.
Source§

impl Debug for EvidentSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more