pub trait Store:
Send
+ Sync
+ 'static {
Show 16 methods
// Required methods
fn execute<'a>(
&'a self,
sql: &'a str,
params: &'a [Value],
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>;
fn fetch<'a>(
&'a self,
sql: &'a str,
params: &'a [Value],
kinds: &'a [ColumnKind],
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, StoreError>> + Send + 'a>>;
fn scan_query<'a>(
&'a self,
schema: &'a Schema,
query: &'a Query,
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, StoreError>> + Send + 'a>>;
fn total_query<'a>(
&'a self,
schema: &'a Schema,
query: &'a Query,
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>;
fn define<'a>(
&'a self,
schema: &'a Schema,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'a>>;
fn create<'a>(
&'a self,
schema: &'a Schema,
batch: &'a [Vec<(Name, Value)>],
) -> Pin<Box<dyn Future<Output = Result<Vec<Key>, StoreError>> + Send + 'a>>;
fn replace<'a>(
&'a self,
schema: &'a Schema,
key: &'a Key,
cells: &'a [(Name, Value)],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'a>>;
fn upsert<'a>(
&'a self,
schema: &'a Schema,
batch: &'a [Vec<(Name, Value)>],
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>;
fn remove<'a>(
&'a self,
schema: &'a Schema,
key: &'a Key,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'a>>;
fn evolve<'a>(
&'a self,
schema: &'a Schema,
drop: bool,
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>;
fn mass<'a>(
&'a self,
schema: &'a Schema,
query: &'a Query,
) -> Pin<Box<dyn Future<Output = Result<Value, StoreError>> + Send + 'a>>;
fn last_id<'a>(
&'a self,
table: &'a str,
) -> Pin<Box<dyn Future<Output = Result<i64, StoreError>> + Send + 'a>>;
// Provided methods
fn columns<'a>(
&'a self,
table: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Column>, StoreError>> + Send + 'a>> { ... }
fn insert<'a>(
&'a self,
table: &'a str,
columns: &'a [String],
values: &'a [Value],
) -> Pin<Box<dyn Future<Output = Result<i64, StoreError>> + Send + 'a>> { ... }
fn deal<'a>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Store>, StoreError>> + Send + 'a>> { ... }
fn settle(
self: Arc<Self>,
commit: bool,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send>> { ... }
}Expand description
A database backend: SQL and typed schema operations over a connection.
Required Methods§
Sourcefn execute<'a>(
&'a self,
sql: &'a str,
params: &'a [Value],
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>
fn execute<'a>( &'a self, sql: &'a str, params: &'a [Value], ) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>
Runs sql with params, returning rows affected.
Sourcefn fetch<'a>(
&'a self,
sql: &'a str,
params: &'a [Value],
kinds: &'a [ColumnKind],
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, StoreError>> + Send + 'a>>
fn fetch<'a>( &'a self, sql: &'a str, params: &'a [Value], kinds: &'a [ColumnKind], ) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, StoreError>> + Send + 'a>>
Runs sql with params, decoding rows per kinds.
Sourcefn scan_query<'a>(
&'a self,
schema: &'a Schema,
query: &'a Query,
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, StoreError>> + Send + 'a>>
fn scan_query<'a>( &'a self, schema: &'a Schema, query: &'a Query, ) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, StoreError>> + Send + 'a>>
Fetches the rows of schema matching query.
Sourcefn total_query<'a>(
&'a self,
schema: &'a Schema,
query: &'a Query,
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>
fn total_query<'a>( &'a self, schema: &'a Schema, query: &'a Query, ) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>
Counts the rows of schema matching query.
Sourcefn define<'a>(
&'a self,
schema: &'a Schema,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'a>>
fn define<'a>( &'a self, schema: &'a Schema, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'a>>
Creates schema’s table if absent.
Sourcefn create<'a>(
&'a self,
schema: &'a Schema,
batch: &'a [Vec<(Name, Value)>],
) -> Pin<Box<dyn Future<Output = Result<Vec<Key>, StoreError>> + Send + 'a>>
fn create<'a>( &'a self, schema: &'a Schema, batch: &'a [Vec<(Name, Value)>], ) -> Pin<Box<dyn Future<Output = Result<Vec<Key>, StoreError>> + Send + 'a>>
Inserts a batch of schema rows, returning each new row’s key.
Sourcefn replace<'a>(
&'a self,
schema: &'a Schema,
key: &'a Key,
cells: &'a [(Name, Value)],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'a>>
fn replace<'a>( &'a self, schema: &'a Schema, key: &'a Key, cells: &'a [(Name, Value)], ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'a>>
Overwrites key’s row of schema with cells.
Sourcefn upsert<'a>(
&'a self,
schema: &'a Schema,
batch: &'a [Vec<(Name, Value)>],
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>
fn upsert<'a>( &'a self, schema: &'a Schema, batch: &'a [Vec<(Name, Value)>], ) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>
Inserts a schema batch, overwriting any matching keys, returning rows touched.
Sourcefn remove<'a>(
&'a self,
schema: &'a Schema,
key: &'a Key,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'a>>
fn remove<'a>( &'a self, schema: &'a Schema, key: &'a Key, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'a>>
Deletes key’s row of schema.
Sourcefn evolve<'a>(
&'a self,
schema: &'a Schema,
drop: bool,
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>
fn evolve<'a>( &'a self, schema: &'a Schema, drop: bool, ) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'a>>
Migrates schema’s table to the latest definition, returning statements run.
Provided Methods§
Sourcefn columns<'a>(
&'a self,
table: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Column>, StoreError>> + Send + 'a>>
fn columns<'a>( &'a self, table: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Column>, StoreError>> + Send + 'a>>
Introspects the columns of table.
Sourcefn insert<'a>(
&'a self,
table: &'a str,
columns: &'a [String],
values: &'a [Value],
) -> Pin<Box<dyn Future<Output = Result<i64, StoreError>> + Send + 'a>>
fn insert<'a>( &'a self, table: &'a str, columns: &'a [String], values: &'a [Value], ) -> Pin<Box<dyn Future<Output = Result<i64, StoreError>> + Send + 'a>>
Raw single-row insert into table returning its id.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".