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
//! Component configuration variables.
//!
//! 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
//! # fn main() -> anyhow::Result<()> {
//! let region = spin_sdk::variables::get("region_id")?;
//! 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;
//!
//! # fn main() -> anyhow::Result<()> {
//! let favourite = match spin_sdk::variables::get("favourite") {
//! Ok(value) => value,
//! Err(Error::Undefined(_)) => "not playing favourites".to_owned(),
//! Err(e) => anyhow::bail!(e),
//! };
//! # Ok(())
//! # }
//! ```
/// Get the value of a component variable.
///
/// # Examples
///
/// Get the value of a component variable.
///
/// ```no_run
/// # fn main() -> anyhow::Result<()> {
/// let region = spin_sdk::variables::get("region_id")?;
/// 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;
///
/// # fn main() -> anyhow::Result<()> {
/// let favourite = match spin_sdk::variables::get("favourite") {
/// Ok(value) => value,
/// Err(Error::Undefined(_)) => "not playing favourites".to_owned(),
/// Err(e) => anyhow::bail!(e),
/// };
/// # Ok(())
/// # }
/// ```
pub use get;
pub use Error;