pub struct Client { /* private fields */ }Expand description
A connection to one FeltDB server. Cheap to clone; clones share the connection pool and token.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn capabilities(&self) -> Result<Value>
pub async fn capabilities(&self) -> Result<Value>
The server’s versioned capability declaration.
Source§impl Client
impl Client
Sourcepub async fn get(&self, collection: &str, id: &str) -> Result<Option<Record>>
pub async fn get(&self, collection: &str, id: &str) -> Result<Option<Record>>
The record collection/id, or None if it does not exist.
Sourcepub async fn list(&self, collection: &str) -> Result<Vec<Record>>
pub async fn list(&self, collection: &str) -> Result<Vec<Record>>
Every record of collection. This reads the whole collection: on a request path use
Client::query, which is bounded.
Sourcepub async fn create(
&self,
collection: &str,
id: Option<&str>,
value: Value,
) -> Result<Record>
pub async fn create( &self, collection: &str, id: Option<&str>, value: Value, ) -> Result<Record>
Create a record only if id is free; refused with HTTP 409 if it exists. value must be a
JSON object. Without an id, the server assigns one.
Sourcepub async fn update(
&self,
collection: &str,
id: &str,
changes: Map<String, Value>,
) -> Result<Record>
pub async fn update( &self, collection: &str, id: &str, changes: Map<String, Value>, ) -> Result<Record>
Merge changes into an existing record (unconditionally). Refused with HTTP 404 if the
record does not exist; use a Transaction or Client::compare_and_set to fence it.
Sourcepub async fn delete(&self, collection: &str, id: &str) -> Result<()>
pub async fn delete(&self, collection: &str, id: &str) -> Result<()>
Delete an existing record. Refused with HTTP 404 if it does not exist.
Sourcepub async fn compare_and_set(
&self,
collection: &str,
id: &str,
request: &CasRequest,
) -> Result<CasOutcome>
pub async fn compare_and_set( &self, collection: &str, id: &str, request: &CasRequest, ) -> Result<CasOutcome>
Replace a record if it still has the version (and epoch and lease) you read.
Sourcepub async fn commit(&self, transaction: &Transaction) -> Result<CommitReceipt>
pub async fn commit(&self, transaction: &Transaction) -> Result<CommitReceipt>
Commit a transaction atomically. A refusal applied nothing; a failed precondition or fence
is reported in Error::precondition_failure.
Sourcepub async fn read_basis(&self, reads: &ReadSet) -> Result<ReadBasis>
pub async fn read_basis(&self, reads: &ReadSet) -> Result<ReadBasis>
Capture what the authority holds for reads, to fence a later transaction on it.
Sourcepub async fn query(&self, query: &BoundedQuery) -> Result<QueryPage>
pub async fn query(&self, query: &BoundedQuery) -> Result<QueryPage>
Run one page of a bounded query.
Source§impl Client
impl Client
Sourcepub fn builder(url: impl Into<String>) -> ClientBuilder
pub fn builder(url: impl Into<String>) -> ClientBuilder
Start configuring a client for the server at url, e.g. http://127.0.0.1:7700.
Sourcepub fn set_token(&self, token: impl Into<String>)
pub fn set_token(&self, token: impl Into<String>)
Replace the bearer token (or clear it with an empty string) for this client and its clones.
Sourcepub fn application(&self, application_id: impl Into<String>) -> Application
pub fn application(&self, application_id: impl Into<String>) -> Application
A handle on one application’s canonical Service API, in its production environment
unless Application::environment says otherwise.