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
//! Typed binding helpers for the Workers `Env`.
//!
//! WHY: `env.d1("NAME")`, `env.secret("NAME")`, etc. return raw `JsValue` /
//! `Result<T, Error>` types. Every Workers crate writes the same 3-line binding
//! extraction. Centralising it here means one place to get it right.
//!
//! WHAT: thin wrappers around `Env::d1`, `Env::secret`, `Env::kv`, `Env::r2`
//! that convert to the `foundation_db` / native Rust types the rest of the
//! platform expects.
use ;
/// Extract a D1 database binding from the Worker environment.
///
/// The binding name must match `[[d1_databases]]` in `wrangler.toml`.
///
/// # Errors
///
/// Returns `worker::Error` if the binding is missing or has the wrong type.
/// Extract a KV namespace binding from the Worker environment.
///
/// # Errors
///
/// Returns `worker::Error` if the binding is missing or has the wrong type.
/// Extract an R2 bucket binding from the Worker environment.
///
/// # Errors
///
/// Returns `worker::Error` if the binding is missing or has the wrong type.
/// Extract a secret binding from the Worker environment.
///
/// Secrets are set via `wrangler secret put <NAME>` and exposed as env bindings.
///
/// # Errors
///
/// Returns `worker::Error` if the binding is missing.
/// Extract a Durable Object namespace binding from the Worker environment.
///
/// # Errors
///
/// Returns `worker::Error` if the binding is missing.