Skip to main content

Store

Trait Store 

Source
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§

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn define<'a>( &'a self, schema: &'a Schema, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'a>>

Creates schema’s table if absent.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn mass<'a>( &'a self, schema: &'a Schema, query: &'a Query, ) -> Pin<Box<dyn Future<Output = Result<Value, StoreError>> + Send + 'a>>

Aggregates schema rows matching query per query.mass.

Source

fn last_id<'a>( &'a self, table: &'a str, ) -> Pin<Box<dyn Future<Output = Result<i64, StoreError>> + Send + 'a>>

Last autoincrement id inserted into table.

Provided Methods§

Source

fn columns<'a>( &'a self, table: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Column>, StoreError>> + Send + 'a>>

Introspects the columns of table.

Source

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.

Source

fn deal<'a>( &'a self, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Store>, StoreError>> + Send + 'a>>

Opens a transaction as an independent Store.

Source

fn settle( self: Arc<Self>, commit: bool, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send>>

Commits or rolls back the transaction from Store::deal.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§