pub trait DatabaseService: Send + Sync {
// Required methods
fn execute<'life0, 'async_trait>(
&'life0 self,
query: Query,
) -> Pin<Box<dyn Future<Output = Result<usize, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn execute_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn query_one<'life0, 'async_trait, T, F>(
&'life0 self,
query: Query,
mapper: F,
) -> Pin<Box<dyn Future<Output = Result<T, String>> + Send + 'async_trait>>
where T: Send + 'static + 'async_trait,
F: Fn(&Row<'_>) -> SqliteResult<T> + Send + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn query_optional<'life0, 'async_trait, T, F>(
&'life0 self,
query: Query,
mapper: F,
) -> Pin<Box<dyn Future<Output = Result<Option<T>, String>> + Send + 'async_trait>>
where T: Send + 'static + 'async_trait,
F: Fn(&Row<'_>) -> SqliteResult<T> + Send + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn query_many<'life0, 'async_trait, T, F>(
&'life0 self,
query: Query,
mapper: F,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, String>> + Send + 'async_trait>>
where T: Send + 'static + 'async_trait,
F: Fn(&Row<'_>) -> SqliteResult<T> + Send + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn transaction<'life0, 'async_trait, F, T>(
&'life0 self,
f: F,
) -> Pin<Box<dyn Future<Output = Result<T, String>> + Send + 'async_trait>>
where F: FnOnce(&mut Transaction<'_>) -> Result<T, String> + Send + 'static + 'async_trait,
T: Send + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn last_insert_rowid<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<i64, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Database service trait - abstraction over database operations
Required Methods§
Sourcefn execute<'life0, 'async_trait>(
&'life0 self,
query: Query,
) -> Pin<Box<dyn Future<Output = Result<usize, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
query: Query,
) -> Pin<Box<dyn Future<Output = Result<usize, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute a query that doesn’t return results (INSERT, UPDATE, DELETE)
Sourcefn execute_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute a batch of SQL statements (for migrations)
Sourcefn query_one<'life0, 'async_trait, T, F>(
&'life0 self,
query: Query,
mapper: F,
) -> Pin<Box<dyn Future<Output = Result<T, String>> + Send + 'async_trait>>
fn query_one<'life0, 'async_trait, T, F>( &'life0 self, query: Query, mapper: F, ) -> Pin<Box<dyn Future<Output = Result<T, String>> + Send + 'async_trait>>
Query a single row
Sourcefn query_optional<'life0, 'async_trait, T, F>(
&'life0 self,
query: Query,
mapper: F,
) -> Pin<Box<dyn Future<Output = Result<Option<T>, String>> + Send + 'async_trait>>
fn query_optional<'life0, 'async_trait, T, F>( &'life0 self, query: Query, mapper: F, ) -> Pin<Box<dyn Future<Output = Result<Option<T>, String>> + Send + 'async_trait>>
Query a single optional row
Sourcefn query_many<'life0, 'async_trait, T, F>(
&'life0 self,
query: Query,
mapper: F,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, String>> + Send + 'async_trait>>
fn query_many<'life0, 'async_trait, T, F>( &'life0 self, query: Query, mapper: F, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>, String>> + Send + 'async_trait>>
Query multiple rows
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.