encore-dev 2.0.0

Rust SDK for Encore applications
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Secret declarations. Nothing here reads a secret, which needs a runtime:
//! the declarations are checked, and what `value` gives.

use encore::secrets::{Secret, Value};

// Each scope is the one type, `String` unless it says otherwise.
static API_KEY: Secret = Secret::new("ApiKey").shared();
static SIGNING_KEY: Secret<String> = Secret::new("SigningKey");
static LICENSE: Secret = Secret::new("License").global();

#[test]
fn a_secret_is_declared_with_its_scope() {
    assert_eq!(API_KEY.name(), "ApiKey");
    assert_eq!(SIGNING_KEY.name(), "SigningKey");
    assert_eq!(LICENSE.name(), "License");
    // What `value` gives: the value, or a panic.
    let _: fn(&Secret) -> Value<String> = Secret::value;
}