pub trait VirtualDatabase: Send + Sync {
// Required methods
fn initialize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<Vec<HashMap<String, Value>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn execute_with_id<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn table_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
table_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn create_table<'life0, 'life1, 'async_trait>(
&'life0 self,
create_statement: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn connection_info(&self) -> String;
fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Virtual database abstraction trait
This trait allows the VBR engine to work with different storage backends transparently, supporting SQLite, JSON files, and in-memory storage.
Required Methods§
Sourcefn initialize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn initialize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Initialize the database and create necessary tables/schemas
Sourcefn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<Vec<HashMap<String, Value>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<Vec<HashMap<String, Value>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute a query that returns rows (SELECT)
Sourcefn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute a query that modifies data (INSERT, UPDATE, DELETE)
Sourcefn execute_with_id<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute_with_id<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute a query and return the last inserted row ID
Sourcefn table_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
table_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn table_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
table_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if a table exists
Sourcefn create_table<'life0, 'life1, 'async_trait>(
&'life0 self,
create_statement: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create_table<'life0, 'life1, 'async_trait>(
&'life0 self,
create_statement: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create a table from a CREATE TABLE statement
Sourcefn connection_info(&self) -> String
fn connection_info(&self) -> String
Get database connection information (for debugging)