Skip to main content

Rust SDK quick reference for agents

Baseline: crate ekodb_client 0.37.0. Install with cargo add ekodb_client@=0.37.0 and use the application's Tokio runtime. Checked against the client, record types and CRUD example.

Runnable Examples (Check Before Guessing)​

Before writing SDK code, consult the matching runnable example below for exact imports, method signatures and error handling. These links follow the SDK's main branch; compare them with the version installed in your application. Follow the language directory's run instructions and use a disposable deployment when executing examples that write data.

TaskRunnable example
CRUDexamples/client_simple_crud.rs
QueryBuilderexamples/client_query_builder.rs
Joinsexamples/client_joins.rs
Schemasexamples/client_schema.rs
TTLexamples/client_document_ttl.rs
Transactionsexamples/client_transactions.rs
Stored Functionsexamples/client_functions.rs
Concurrency / Locks / RateLimitsexamples/client_concurrency_stages.rs
Chat / RAGexamples/client_chat_basic.rs, examples/rag_conversation_system.rs
Searchexamples/client_search.rs
WebSocketsexamples/client_websocket_subscribe.rs
Admin / Permissionsexamples/client_admin.rs

Initialize and query​

use ekodb_client::{Client, QueryBuilder, Record};

async fn list_active(
base_url: &str,
api_key: &str,
) -> Result<Vec<Record>, Box<dyn std::error::Error>> {
let client = Client::builder().base_url(base_url).api_key(api_key).build()?;
let query = QueryBuilder::new().eq("active", true).limit(25).build();
Ok(client.find("agent_tasks", query, None).await?)
}

The application supplies runtime credentials. The client exchanges and refreshes tokens. Builder build() is synchronous; database operations are async. The third find argument is an optional ripple flag, not a query options object.

Method map​

TaskCall shape (await the result)
Insertclient.insert(collection, record, None)
Findclient.find(collection, query, None)
Point readclient.find_by_id(collection, id, None)
Merge updateclient.update(collection, id, fields, None)
Deleteclient.delete(collection, id, None)
Read schemaclient.get_schema(collection)
Save / call a functionclient.save_user_function(definition) / client.call_function(id_or_label, params)
Transactionsclient.begin_transaction(None), client.commit_transaction(id), client.rollback_transaction(id)

The explicit None arguments matter: Rust does not omit optional parameters. The last insert/update arguments are Option<InsertOptions> / Option<UpdateOptions>; find/point-read's last argument is Option<bool>. Use the separate find_in_transaction / find_by_id_in_transaction methods for transactional reads, and write option structs carrying transaction_id for staged writes.

Values, TTL and failures​

  • Build data with Record::new() and record.insert(name, value). Use FieldType::array, the FieldType::Object variant or native JSON conversion for nested data; do not serialize an object into a string.
  • Records contain FieldType. record.get_string("id") and get_bool("active") handle plain values and typed wrappers. Match the enum or use the appropriate extraction helper for other types.
  • Record::with_ttl("5m") carries the TTL directive. Include it on the update only to set a new expiry; omitting it preserves the stored expiry.
  • A function call returns FunctionResult; read result.records[0] for a Count result, then its named output field. Count replaces the input rows.
  • Return Result errors to the caller. Error::Transaction { code, message, .. } preserves transaction status and displays Transaction error (409) for a conflict response. Commit is not automatically retried; distinguish a concurrency conflict from legacy Apply(...) failures before starting a new transaction.

See canonical formats, the error type and versioned Rust examples.