pub struct RusqliteService {
writer: Arc<Writer>,
readers: Option<Arc<ReaderPool>>,
}Expand description
Rusqlite-based database service: a cheap, cloneable handle to the writer thread and reader pool. See the module docs.
Fields§
§writer: Arc<Writer>§readers: Option<Arc<ReaderPool>>Implementations§
Source§impl RusqliteService
impl RusqliteService
Sourcepub fn new(conn: Arc<Mutex<Connection>>) -> Self
pub fn new(conn: Arc<Mutex<Connection>>) -> Self
A service over a single connection: writes and reads go through the writer thread. Used for in-memory databases, which cannot be shared between connections.
Sourcepub fn with_readers(
conn: Arc<Mutex<Connection>>,
readers: Vec<Connection>,
) -> Self
pub fn with_readers( conn: Arc<Mutex<Connection>>, readers: Vec<Connection>, ) -> Self
A service whose reads run on readers — read-only connections to the
same (file-backed, WAL-mode) database — alongside the writer.
async fn read<T, F>(&self, f: F) -> Result<T, String>
Trait Implementations§
Source§impl Clone for RusqliteService
impl Clone for RusqliteService
Source§fn clone(&self) -> RusqliteService
fn clone(&self) -> RusqliteService
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl DatabaseService for RusqliteService
impl DatabaseService for RusqliteService
Source§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<'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)
Source§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 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)
Source§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>>
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
Source§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>>
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
Source§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>>
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
Source§fn transaction<'life0, 'async_trait, F, T>(
&'life0 self,
f: F,
) -> Pin<Box<dyn Future<Output = Result<T, String>> + Send + 'async_trait>>
fn transaction<'life0, 'async_trait, F, T>( &'life0 self, f: F, ) -> Pin<Box<dyn Future<Output = Result<T, String>> + Send + 'async_trait>>
Run a transaction with multiple operations
Source§fn transaction_without_foreign_keys<'life0, 'async_trait, F, T>(
&'life0 self,
f: F,
) -> Pin<Box<dyn Future<Output = Result<T, String>> + Send + 'async_trait>>
fn transaction_without_foreign_keys<'life0, 'async_trait, F, T>( &'life0 self, f: F, ) -> Pin<Box<dyn Future<Output = Result<T, String>> + Send + 'async_trait>>
Run a transaction with foreign-key enforcement switched off for its
duration only. Read more
Source§fn insert<'life0, 'async_trait>(
&'life0 self,
query: Query,
) -> Pin<Box<dyn Future<Output = Result<i64, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn insert<'life0, 'async_trait>(
&'life0 self,
query: Query,
) -> Pin<Box<dyn Future<Output = Result<i64, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute an INSERT and return the rowid of the row it inserted. Read more
Source§fn execute_detached(&self, query: Query)
fn execute_detached(&self, query: Query)
Queue a write without waiting for it — for best-effort bookkeeping (an
LRU access time) that must not hold up the caller. It still runs in
order with every other write; failures are only logged.
Auto Trait Implementations§
impl Freeze for RusqliteService
impl RefUnwindSafe for RusqliteService
impl Send for RusqliteService
impl Sync for RusqliteService
impl Unpin for RusqliteService
impl UnsafeUnpin for RusqliteService
impl UnwindSafe for RusqliteService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more