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
use crateResult;
use crateTask;
use Database;
/// Wrapper for graceful shutdown integration with [`crate::run!`].
///
/// Wraps a [`Database`] so it can be registered as a [`Task`] with the
/// modo runtime. On shutdown the inner `Database` is dropped, which
/// releases the underlying libsql connection and database handle once the
/// last clone is gone.
///
/// Created by [`managed`].
;
/// Wrap a [`Database`] for use with [`crate::run!`].
///
/// # Examples
///
/// ```rust,no_run
/// use modo::db;
///
/// # async fn example() -> modo::Result<()> {
/// let config = db::Config::default();
/// let db = db::connect(&config).await?;
/// let task = db::managed(db.clone());
/// // Register `task` with modo::run!() for graceful shutdown
/// # Ok(())
/// # }
/// ```