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
impl AmateRSClient
Sourcepub async fn connect(addr: impl Into<String>) -> Result<Self>
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?;Sourcepub async fn connect_with_config(config: ClientConfig) -> Result<Self>
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?;Sourcepub fn with_encryptor(self, encryptor: FheEncryptor) -> Self
pub fn with_encryptor(self, encryptor: FheEncryptor) -> Self
Set the FHE encryptor for client-side encryption
Sourcepub fn encryptor(&self) -> Option<&Arc<FheEncryptor>>
pub fn encryptor(&self) -> Option<&Arc<FheEncryptor>>
Get the encryptor (if set)
Sourcepub fn with_cache(self, config: QueryCacheConfig) -> Self
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)));Sourcepub fn cache(&self) -> Option<&Arc<QueryCache>>
pub fn cache(&self) -> Option<&Arc<QueryCache>>
Get a reference to the cache (if enabled).
Sourcepub async fn set(
&self,
collection: &str,
key: &Key,
value: &CipherBlob,
) -> Result<()>
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?;Sourcepub async fn get(
&self,
collection: &str,
key: &Key,
) -> Result<Option<CipherBlob>>
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());
}Sourcepub async fn delete(&self, collection: &str, key: &Key) -> Result<()>
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?;Sourcepub async fn contains(&self, collection: &str, key: &Key) -> Result<bool>
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");
}Sourcepub async fn execute_query(&self, query: &Query) -> Result<QueryResult>
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?;Sourcepub async fn execute_batch(
&self,
queries: Vec<Query>,
) -> Result<Vec<QueryResult>>
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).
Sourcepub fn pool_stats(&self) -> PoolStats
pub fn pool_stats(&self) -> PoolStats
Get connection pool statistics
Sourcepub async fn health_check(&self) -> Result<()>
pub async fn health_check(&self) -> Result<()>
Health check
Returns Ok(()) if the server is healthy.
Sourcepub async fn server_info(&self) -> Result<ServerInfo>
pub async fn server_info(&self) -> Result<ServerInfo>
Get server information
Returns information about the server including version, capabilities, and uptime.
Sourcepub async fn range(
&self,
collection: &str,
start: &Key,
end: &Key,
) -> Result<Vec<(Key, CipherBlob)>>
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());Sourcepub async fn range_paginated(
&self,
collection: &str,
start: &Key,
end: &Key,
page_size: usize,
) -> Result<PaginatedResult<(Key, CipherBlob)>>
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.
Sourcepub async fn range_with_cursor(
&self,
collection: &str,
start: &Key,
end: &Key,
pagination: &PaginationConfig,
) -> Result<PaginatedResult<(Key, CipherBlob)>>
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.
Sourcepub async fn range_sorted(
&self,
collection: &str,
start: &Key,
end: &Key,
sort: &SortConfig,
) -> Result<Vec<(Key, CipherBlob)>>
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.
Sourcepub async fn scan(
&self,
collection: &str,
prefix: &Key,
pagination: &PaginationConfig,
) -> Result<PaginatedResult<(Key, CipherBlob)>>
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.
Sourcepub async fn count(&self, collection: &str) -> Result<usize>
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.
Sourcepub async fn stream_query(
&self,
query: Query,
config: StreamConfig,
) -> Result<QueryStream>
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
impl Clone for AmateRSClient
Source§fn clone(&self) -> AmateRSClient
fn clone(&self) -> AmateRSClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AmateRSClient
impl !RefUnwindSafe for AmateRSClient
impl Send for AmateRSClient
impl Sync for AmateRSClient
impl Unpin for AmateRSClient
impl UnsafeUnpin for AmateRSClient
impl !UnwindSafe for AmateRSClient
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.