1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! DbConnectionBlocking trait for backends that are natively synchronous.
use crateDbError;
use FromRow;
use Value;
/// Synchronous counterpart to [`DbConnection`](crate::trait_def::DbConnection),
/// for in-process drivers that are natively blocking.
///
/// Only `RusqliteConnection` implements it: SQLite runs in the calling process and
/// never yields, so nothing is gained by going through a runtime. libsql and
/// Postgres talk to a server and are genuinely async; a blocking wrapper there
/// would only hide a `block_on`.
///
/// Reach for this when the consumer has no async of its own -- a CLI that would
/// otherwise build a runtime per invocation -- or when it already runs its database
/// work on a blocking thread and does not want a second thread hop underneath.
///
/// `RusqliteConnection` implements this *and* `DbConnection`, and the two traits
/// share method names. With both in scope a plain `conn.execute_sql(..)` is
/// ambiguous (`E0034`); name the trait to pick a path:
///
/// ```ignore
/// DbConnectionBlocking::execute_sql(&conn, sql, params)?;
/// DbConnection::execute_sql(&conn, sql, params).await?;
/// ```