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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// This module exists to allow us to write hidden compile_fail doc tests that assert our types have the appropriate lifetimes.
/// // Make sure a tx cannot outlife a db.
/// ```compile_fail
/// use jammdb::{DB, Tx, Error};
///
/// fn main() -> Result<(), Error> {
/// let tx: Tx;
/// {
/// // open a new database file
/// let db = DB::open("my-database.db")?;
///
/// // open a writable transaction so we can make changes
/// tx = db.tx(true)?;
/// }
/// let names_bucket = tx.get_bucket("names")?;
/// Ok(())
/// }
///
/// ```
///
;
/// // Make sure a bucket cannot outlife a tx.
/// ```compile_fail
/// use jammdb::{DB, Bucket, Error};
///
/// fn main() -> Result<(), Error> {
/// // open a new database file
/// let db = DB::open("my-database.db")?;
/// let b: Bucket;
/// {
/// // open a writable transaction so we can make changes
/// let tx = db.tx(true)?;
/// b = tx.get_bucket("names")?;
/// }
/// b.put("abc", "def");
/// Ok(())
/// }
///
/// ```
///
;
/// // Make sure a kv-pair cannot outlive a tx.
/// ```compile_fail
/// use jammdb::{DB, KVPair, Error};
///
/// fn main() -> Result<(), Error> {
/// // open a new database file
/// let db = DB::open("my-database.db")?;
/// let kv: KVPair;
/// {
/// // open a writable transaction so we can make changes
/// let tx = db.tx(true)?;
/// let b = tx.get_bucket("names")?;
/// kv = b.get_kv("data").unwrap();
/// }
/// let key = kv.key();
/// Ok(())
/// }
/// ```
///
;