Crate ekodb_client

Crate ekodb_client 

Source
Expand description

§ekoDB Client Library

Official Rust client for ekoDB - A high-performance database with intelligent caching, real-time capabilities, and automatic optimization.

§Features

  • Async/Await: Built on Tokio for high-performance async operations
  • Type-Safe: Strong typing with Rust’s type system
  • Auto-Retry: Automatic retry with exponential backoff for transient failures
  • Connection Pooling: Efficient connection management
  • WebSocket Support: Real-time subscriptions and updates
  • Batch Operations: Efficient bulk inserts, updates, and deletes
  • Query Builder: Fluent API for building complex queries

§Quick Start

use ekodb_client::{Client, Record};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a client
    let client = Client::builder()
        .base_url("https://api.ekodb.net")
        .api_key("your-api-key")
        .build()?;

    // Insert a record
    let mut record = Record::new();
    record.insert("name", "John Doe");
    record.insert("age", 30);
     
    let result = client.insert("users", record, None).await?;
    println!("Inserted: {:?}", result);

    Ok(())
}

Structs§

BatchBuilder
Builder for batch operations
ChatMessage
Chat message for AI operations
ChatMessageRequest
Request to send a message in an existing session
ChatRequest
Request to send a chat message
ChatResponse
Response from a chat request
ChatSession
Chat session details
ChatSessionResponse
Response containing chat session information
ChatTextSearchOptions
Text search options for chat context retrieval
Client
ekoDB client
ClientBuilder
Builder for creating a Client
CollectionConfig
Configuration for searching a specific collection
CollectionMetadata
Collection metadata with analytics
ContextSnippet
Context snippet from search results
CreateChatSessionRequest
Request to create a new chat session
FieldSearchOptions
Field-specific search options
FieldTypeSchema
Field type schema with constraints
FunctionResult
Function execution result
FunctionStats
Statistics about function execution
GetMessagesQuery
Query parameters for getting messages
GetMessagesResponse
Response containing messages with pagination metadata
GroupFunctionConfig
Group function configuration for Group stage
JoinConfig
Configuration for joining collections
ListSessionsQuery
Query parameters for listing sessions
ListSessionsResponse
Response containing list of chat sessions
MergeSessionsRequest
Request to merge multiple chat sessions
Models
Available LLM models from different providers
ParameterDefinition
Parameter definition for a function
Query
Query for finding records
QueryBuilder
Builder for constructing complex queries
RateLimitInfo
Rate limit information from the server
Record
A record in ekoDB
Schema
Collection schema
Script
A Script definition with Functions and parameters
SearchQuery
Search query for full-text and vector search
SearchResponse
Search response containing results and metadata
SearchResult
Search result with score and matched fields
SortFieldConfig
Sort field configuration
StageStats
Statistics for a single stage
ToggleForgottenRequest
Request to toggle message forgotten status
TokenUsage
Token usage information from LLM providers
UpdateMessageRequest
Request to update a message
UpdateSessionRequest
Request to update session metadata
UserFunction
A UserFunction is a reusable sequence of Functions that can be called by Scripts
WebSocketClient
WebSocket client for real-time communication with persistent connection

Enums§

DistanceMetric
Distance metric for vector similarity
Error
Errors that can occur when using the ekoDB client
FieldType
Field type representing all supported data types in ekoDB
Function
Function in a Script
GroupFunctionOp
Group function operation type
IndexConfig
Index configuration for a field
MergeStrategy
Merge strategy for combining chat sessions
NumberValue
Flexible numeric value that can be Integer, Float, or Decimal
QueryOperator
Query operators for filtering
ScriptCondition
Condition evaluation for Script control flow (If statements)
SerializationFormat
Serialization format for client-server communication
SortOrder
Sort order for query results
VectorIndexAlgorithm
Vector index algorithm

Constants§

VERSION
Client version

Functions§

extract_record
Transform an entire record by extracting all field values. Preserves the ‘id’ field and extracts values from all other fields.
get_array_value
Extract an array from an ekoDB Array field
get_binary_value
Extract bytes from an ekoDB Binary field
get_bool_value
Extract a boolean value from an ekoDB field
get_bytes_value
Extract bytes from an ekoDB Bytes field
get_datetime_value
Extract a DateTime string from an ekoDB DateTime field
get_decimal_value
Extract a decimal value from an ekoDB Decimal field
get_duration_value
Extract duration in milliseconds from an ekoDB Duration field
get_float_value
Extract a float value from an ekoDB field
get_int_value
Extract an integer value from an ekoDB field
get_object_value
Extract an object from an ekoDB Object field
get_set_value
Extract an array from an ekoDB Set field
get_string_value
Extract a string value from an ekoDB field
get_uuid_value
Extract a UUID string from an ekoDB UUID field
get_value
Extract the value from an ekoDB field object. ekoDB returns fields as {"type": "String", "value": "..."} objects. This helper safely extracts the value or returns the input if it’s not a field object.
get_values
Extract values from multiple fields in a record. Useful for processing entire records returned from ekoDB.
get_vector_value
Extract a vector of floats from an ekoDB Vector field

Type Aliases§

Result
Result type alias for ekoDB client operations