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
//! Component variables must be defined in the application
//! manifest, in the `[component.<name>.variables]` section.
//! Component variables typically use template syntax to
//! derive values from application variables, which are
//! the only variables that may be overridden directly (for
//! example, on the Spin command line).
//!
//! # Examples
//!
//! Get the value of a component variable.
//!
//! ```no_run
//! # async fn run() -> anyhow::Result<()> {
//! let region = spin_sdk::variables::get("region_id").await?;
//! let regional_url = format!("https://{region}.db.example.com");
//! # Ok(())
//! # }
//! ```
//!
//! Fail gracefully if a variable is not set.
//!
//! ```no_run
//! use spin_sdk::variables::Error;
//!
//! # async fn run() -> anyhow::Result<()> {
//! let favourite = match spin_sdk::variables::get("favourite").await {
//! Ok(value) => value,
//! Err(Error::Undefined(_)) => "not playing favourites".to_owned(),
//! Err(e) => anyhow::bail!(e),
//! };
//! # Ok(())
//! # }
//! ```
/// Module containing wit bindgen generated code.
///
/// This is only meant for internal consumption.
pub use Error;
/// Get an application variable value for the current component.
///
/// The name must match one defined in in the component manifest.
pub async