Skip to main content

Client

Struct Client 

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

A client bound to one RPC proxy.

One connection multiplexes every call, so a Client is cheap to share: wrap it in an Arc and call it concurrently rather than opening more.

Implementations§

Source§

impl Client

Source

pub async fn connect(address: &str) -> Result<Self>

Connects to an RPC proxy at host:port.

The address is the one discover_proxies returns, not the HTTP proxy’s.

Source

pub fn builder(address: &str) -> ClientBuilder

Starts configuring a client.

Source

pub fn connection(&self) -> &Connection

The underlying connection, for callers that need to invoke a method this crate does not wrap.

Source

pub async fn discover_proxies(&self, role: Option<&str>) -> Result<Vec<String>>

The addresses of the cluster’s RPC proxies, asked of this one.

Source

pub async fn start_transaction( &self, transaction_type: TransactionType, options: StartTransactionOptions, ) -> Result<Transaction<'_>>

Starts a transaction.

A tablet transaction is sticky: it belongs to the proxy that created it, and every later call in it must go to that same proxy. This client holds one connection, so that happens naturally — but a transaction started here must not be used through another Client.

Source

pub async fn lookup_rows( &self, path: &str, columns: &[&str], keys: &[Row], options: LookupOptions<'_>, ) -> Result<Vec<MaybeRow>>

Looks rows up by key.

keys holds one row per key, carrying only the key columns. The result has one entry per key in the order asked, and a key with no row comes back as None — which is why the rows are Options rather than a shorter list.

Source

pub async fn lookup_rows_with_columns( &self, path: &str, columns: &[&str], keys: &[Row], options: LookupOptions<'_>, ) -> Result<(Vec<MaybeRow>, Vec<String>)>

Looks rows up, returning the names of the columns as well as the rows.

A value carries a numeric id, not a name, and the reply’s descriptor is what resolves them. Callers that map rows onto named columns — the blocking facade, and anything building a serde row — need both.

Source

pub async fn select_rows( &self, query: &str, options: SelectOptions, ) -> Result<Vec<MaybeRow>>

Runs a query and returns its rows.

The returned descriptor names the columns, in the order the values are numbered; select_rows_with_columns hands both back when the caller needs the names.

Source

pub async fn select_rows_with_columns( &self, query: &str, options: SelectOptions, ) -> Result<(Vec<MaybeRow>, Vec<String>)>

Runs a query, returning its rows and the names of their columns.

Trait Implementations§

Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V