Crate amaters_sdk_rust

Crate amaters_sdk_rust 

Source
Expand description

§AmateRS SDK for Rust

This is the official Rust SDK for AmateRS, a Fully Homomorphic Encrypted Database.

§Features

  • Client-side encryption: All encryption/decryption happens on the client
  • Connection pooling: Efficient connection management with automatic reconnection
  • Retry logic: Automatic retries with exponential backoff
  • Type-safe queries: Fluent API for building queries
  • Async-first: Built on Tokio for high performance

§Quick Start

use amaters_sdk_rust::{AmateRSClient, ClientConfig};
use amaters_core::{Key, CipherBlob};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Connect to server
    let client = AmateRSClient::connect("http://localhost:50051").await?;

    // Set a value
    let key = Key::from_str("user:123");
    let value = CipherBlob::new(vec![1, 2, 3, 4]);
    client.set("users", &key, &value).await?;

    // Get a value
    if let Some(retrieved) = client.get("users", &key).await? {
        println!("Retrieved {} bytes", retrieved.len());
    }

    // Delete a key
    client.delete("users", &key).await?;

    Ok(())
}

§Connection Configuration

use amaters_sdk_rust::{AmateRSClient, ClientConfig, RetryConfig};
use std::time::Duration;

let config = ClientConfig::new("http://localhost:50051")
    .with_connect_timeout(Duration::from_secs(5))
    .with_request_timeout(Duration::from_secs(30))
    .with_max_connections(20)
    .with_retry_config(
        RetryConfig::new()
            .with_max_retries(5)
            .with_initial_backoff(Duration::from_millis(100))
    );

let client = AmateRSClient::connect_with_config(config).await?;

§Query Builder

use amaters_sdk_rust::query;
use amaters_core::{Key, CipherBlob, col, Predicate};

// Simple query
let q = query("users").get(Key::from_str("user:123"));

// Filter with predicates
let q = query("users")
    .where_clause()
    .eq(col("status"), CipherBlob::new(vec![1]))
    .and(Predicate::Gt(col("age"), CipherBlob::new(vec![18])))
    .build();

// Range query
let q = query("data").range(
    Key::from_str("start"),
    Key::from_str("end")
);

§FHE Integration

The SDK supports client-side encryption with FHE (feature-gated):

use amaters_sdk_rust::{AmateRSClient, FheEncryptor};

// Create encryptor (stub implementation for now)
let encryptor = FheEncryptor::new()?;

// Connect with encryptor
let client = AmateRSClient::connect("http://localhost:50051")
    .await?
    .with_encryptor(encryptor);

§Feature Flags

  • fhe - Enable full FHE support with TFHE
  • serialization - Enable key serialization with oxicode

Re-exports§

pub use client::AmateRSClient;
pub use client::QueryResult;
pub use client::ServerInfo;
pub use config::ClientConfig;
pub use config::RetryConfig;
pub use config::TlsConfig;
pub use error::Result;
pub use error::SdkError;
pub use fhe::FheEncryptor;
pub use fhe::FheKeys;
pub use query::FilterBuilder;
pub use query::FluentQueryBuilder;
pub use query::PredicateBuilder;
pub use query::query;

Modules§

client
AmateRS client implementation
config
Client configuration types
connection
Connection management and pooling
error
Error types for the AmateRS SDK
fhe
FHE (Fully Homomorphic Encryption) key management and operations
query
Query builder for fluent API construction

Structs§

CipherBlob
Encrypted data blob - immutable, zero-copy friendly
ColumnRef
Reference to a column in the encrypted data
Key
Database key type

Enums§

Predicate
Predicate for filtering (executed on encrypted data via FHE)
Query
Top-level query type
Update
Update operation

Constants§

VERSION
Library version

Functions§

col
Helper function to create a column reference