pub trait TableClient {
// Required methods
fn transport(&self) -> Transport;
fn lookup_rows(
&self,
path: &str,
keys: &[Row],
options: &LookupOptions,
) -> Result<Vec<MaybeRow>>;
fn select_rows(
&self,
query: &str,
options: &SelectOptions,
) -> Result<Vec<Row>>;
fn insert_rows(&self, path: &str, rows: &[Row]) -> Result<()>;
fn delete_rows(&self, path: &str, keys: &[Row]) -> Result<()>;
fn start_transaction(&self) -> Result<Box<dyn TableTransaction + '_>>;
}Expand description
What a dynamic table can be asked to do, whatever the transport.
Implemented by the HTTP client and by the RPC client’s blocking facade. The two are wire-level different and behaviourally the same, which is the whole point.
Required Methods§
Sourcefn transport(&self) -> Transport
fn transport(&self) -> Transport
Which transport this client speaks, for diagnostics and for tests that want to run the same checks against both.
Sourcefn lookup_rows(
&self,
path: &str,
keys: &[Row],
options: &LookupOptions,
) -> Result<Vec<MaybeRow>>
fn lookup_rows( &self, path: &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.
Sourcefn select_rows(&self, query: &str, options: &SelectOptions) -> Result<Vec<Row>>
fn select_rows(&self, query: &str, options: &SelectOptions) -> Result<Vec<Row>>
Runs a query and returns its rows.
Sourcefn insert_rows(&self, path: &str, rows: &[Row]) -> Result<()>
fn insert_rows(&self, path: &str, rows: &[Row]) -> Result<()>
Writes rows outside a transaction.
The transports differ underneath — HTTP has a standalone insert_rows
command, RPC has none and needs a transaction — and this hides that.
Sourcefn delete_rows(&self, path: &str, keys: &[Row]) -> Result<()>
fn delete_rows(&self, path: &str, keys: &[Row]) -> Result<()>
Deletes rows by key, outside a transaction.
Sourcefn start_transaction(&self) -> Result<Box<dyn TableTransaction + '_>>
fn start_transaction(&self) -> Result<Box<dyn TableTransaction + '_>>
Starts a tablet transaction.
Boxed because the transaction types differ per transport and a caller
holding a dyn TableClient cannot name either.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".