Skip to main content

AmateRSClient

Struct AmateRSClient 

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

AmateRS client for interacting with the database

The client manages connections, handles retries, and provides high-level operations for working with encrypted data.

Implementations§

Source§

impl AmateRSClient

Source

pub async fn connect(addr: impl Into<String>) -> Result<Self>

Connect to an AmateRS server

§Example
use amaters_sdk_rust::AmateRSClient;

let client = AmateRSClient::connect("http://localhost:50051").await?;
Source

pub async fn connect_with_config(config: ClientConfig) -> Result<Self>

Connect with a custom configuration

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

let config = ClientConfig::new("http://localhost:50051")
    .with_connect_timeout(Duration::from_secs(5))
    .with_max_connections(20);

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

pub fn with_encryptor(self, encryptor: FheEncryptor) -> Self

Set the FHE encryptor for client-side encryption

Source

pub fn encryptor(&self) -> Option<&Arc<FheEncryptor>>

Get the encryptor (if set)

Source

pub fn with_cache(self, config: QueryCacheConfig) -> Self

Enable client-side query result caching with the given configuration.

§Example
use amaters_sdk_rust::{AmateRSClient, QueryCacheConfig};
use std::time::Duration;

let client = AmateRSClient::connect("http://localhost:50051")
    .await?
    .with_cache(QueryCacheConfig::default().with_ttl(Duration::from_secs(120)));
Source

pub fn cache(&self) -> Option<&Arc<QueryCache>>

Get a reference to the cache (if enabled).

Source

pub async fn set( &self, collection: &str, key: &Key, value: &CipherBlob, ) -> Result<()>

Set a key-value pair

§Example
use amaters_sdk_rust::AmateRSClient;
use amaters_core::{Key, CipherBlob};

let key = Key::from_str("user:123");
let value = CipherBlob::new(vec![1, 2, 3, 4]);

client.set("users", &key, &value).await?;
Source

pub async fn get( &self, collection: &str, key: &Key, ) -> Result<Option<CipherBlob>>

Get a value by key

Returns None if the key doesn’t exist.

§Example
use amaters_sdk_rust::AmateRSClient;
use amaters_core::Key;

let key = Key::from_str("user:123");

if let Some(value) = client.get("users", &key).await? {
    println!("Found value: {} bytes", value.len());
}
Source

pub async fn delete(&self, collection: &str, key: &Key) -> Result<()>

Delete a key

§Example
use amaters_sdk_rust::AmateRSClient;
use amaters_core::Key;

let key = Key::from_str("user:123");
client.delete("users", &key).await?;
Source

pub async fn contains(&self, collection: &str, key: &Key) -> Result<bool>

Check if a key exists

§Example
use amaters_sdk_rust::AmateRSClient;
use amaters_core::Key;

let key = Key::from_str("user:123");

if client.contains("users", &key).await? {
    println!("Key exists");
}
Source

pub async fn execute_query(&self, query: &Query) -> Result<QueryResult>

Execute a query

This is a lower-level method that executes arbitrary queries.

§Example
use amaters_sdk_rust::AmateRSClient;
use amaters_core::{Query, Key};

let query = Query::Get {
    collection: "users".to_string(),
    key: Key::from_str("user:123"),
};

client.execute_query(&query).await?;
Source

pub async fn execute_batch( &self, queries: Vec<Query>, ) -> Result<Vec<QueryResult>>

Execute a batch of queries

All queries are executed atomically (all succeed or all fail).

Source

pub fn pool_stats(&self) -> PoolStats

Get connection pool statistics

Source

pub fn close(&self)

Close all connections

Source

pub async fn health_check(&self) -> Result<()>

Health check

Returns Ok(()) if the server is healthy.

Source

pub async fn server_info(&self) -> Result<ServerInfo>

Get server information

Returns information about the server including version, capabilities, and uptime.

Source

pub async fn range( &self, collection: &str, start: &Key, end: &Key, ) -> Result<Vec<(Key, CipherBlob)>>

Range query - retrieve keys in a range

§Example
use amaters_sdk_rust::AmateRSClient;
use amaters_core::Key;

let start = Key::from_str("user:000");
let end = Key::from_str("user:999");

let results = client.range("users", &start, &end).await?;
println!("Found {} keys in range", results.len());
Source

pub async fn range_paginated( &self, collection: &str, start: &Key, end: &Key, page_size: usize, ) -> Result<PaginatedResult<(Key, CipherBlob)>>

Range query with simple pagination.

Returns the first page_size items in the range [start, end). Use the returned cursor to fetch subsequent pages via Self::range_with_cursor.

Source

pub async fn range_with_cursor( &self, collection: &str, start: &Key, end: &Key, pagination: &PaginationConfig, ) -> Result<PaginatedResult<(Key, CipherBlob)>>

Range query with full cursor-based pagination.

If pagination.cursor is Some, the scan resumes from the key encoded in the cursor (exclusive). Otherwise it starts from start.

Source

pub async fn range_sorted( &self, collection: &str, start: &Key, end: &Key, sort: &SortConfig, ) -> Result<Vec<(Key, CipherBlob)>>

Range query with results sorted according to sort.

The full range is fetched from the server and then sorted client-side.

Source

pub async fn scan( &self, collection: &str, prefix: &Key, pagination: &PaginationConfig, ) -> Result<PaginatedResult<(Key, CipherBlob)>>

Scan keys with a given prefix, returning paginated results.

This constructs a range [prefix, prefix_end) where prefix_end is the lexicographic successor of prefix, then delegates to Self::range_with_cursor.

Source

pub async fn count(&self, collection: &str) -> Result<usize>

Count the number of keys in a collection.

This performs a full range scan and counts the results. For very large collections a server-side count would be more efficient, but this provides a correct answer using the existing API surface.

Source

pub async fn stream_query( &self, query: Query, config: StreamConfig, ) -> Result<QueryStream>

Stream query results row by row using a real gRPC server-streaming RPC.

Returns a QueryStream that implements futures::Stream. The stream is backed by a bounded mpsc channel (capacity = config.buffer_size) so the producer is automatically throttled when the consumer is slow. Dropping the returned stream cancels the background task.

The server currently supports Range and Get queries for streaming. Other query variants will be rejected by the server with a gRPC error that is forwarded to the stream as Err(SdkError::Grpc(...)).

Returns Err(SdkError::Connection(...)) if there is no live server connection available.

Trait Implementations§

Source§

impl Clone for AmateRSClient

Source§

fn clone(&self) -> AmateRSClient

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

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<Input, Output> CastInto<Output> for Input
where Output: CastFrom<Input>,

Source§

fn cast_into(self) -> Output

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<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