pub struct Secret<T: SecretValue = String> { /* private fields */ }Expand description
A secret, declared as a module-level static: its name, and its value
once read. See the module documentation.
new declares a secret of the service that declares it;
shared and global make it the whole
app’s. The scope is the declaration’s, which Encore reads from the source:
a name has one scope across the app, so the value is looked up by name.
Implementations§
Source§impl<T: SecretValue> Secret<T>
impl<T: SecretValue> Secret<T>
Sourcepub const fn new(name: &'static str) -> Self
pub const fn new(name: &'static str) -> Self
Declare a secret by name. const so it can initialize a module-scope
static; nothing is resolved until its value is asked for. The name
must be a string literal: Encore reads it from the source.
Makes the secret one value for the whole app, rather than the declaring service’s own. Any service may declare it, and each that reads it is granted access to it. See scope.
Sourcepub const fn global(self) -> Self
pub const fn global(self) -> Self
Makes the secret one value for the whole app, available to every service without being granted. See scope.
Sourcepub const fn description(self, _description: &'static str) -> Self
pub const fn description(self, _description: &'static str) -> Self
Documents the secret: what it is, who issues it and how to rotate it, shown wherever its values are managed. Read by Encore’s parser, so it must be a string literal; the declaration’s doc comment wins when there is one.
static API_KEY: Secret = Secret::new("ApiKey")
.description("Issued by Acme Pay. Rotate it in their portal.");Sourcepub const fn tag(self, _key: &'static str, _value: &'static str) -> Self
pub const fn tag(self, _key: &'static str, _value: &'static str) -> Self
Tags the secret with key and value: key/value classification, such
as .tag("data", "pci"), for policies to read. One call per tag, each
with its own key. Encore reads them from the source, so both are string
literals. A key is lowercase letters, digits, _ and -, starting with
a letter and not with encore, which is kept for Encore’s own tags; a
value is the same characters, or empty. Each is at most 63 characters,
and a secret has at most 32 tags.
Part of the declaration: it takes the secret by value, so it cannot be
called on the static.
static API_KEY: Secret = Secret::new("ApiKey").tag("data", "pci");Trait Implementations§
Source§impl<'de, T: SecretValue> Deserialize<'de> for Secret<T>
A config’s secret field: read from the placeholder the runtime puts where
the field goes, which names the secret. Its scope is the config’s own (a
service’s own config reads that service’s secret, a shared or global config
one of the app’s), and a name has one scope across the app, so the name
alone says which. See the config module.
impl<'de, T: SecretValue> Deserialize<'de> for Secret<T>
A config’s secret field: read from the placeholder the runtime puts where
the field goes, which names the secret. Its scope is the config’s own (a
service’s own config reads that service’s secret, a shared or global config
one of the app’s), and a name has one scope across the app, so the name
alone says which. See the config module.
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl<T: SecretValue> Serialize for Secret<T>
A config’s secret field written back as the placeholder it was read
from, never its value: what testing::set_config leaves out of a value
it is given, as config can’t set a secret field.
impl<T: SecretValue> Serialize for Secret<T>
A config’s secret field written back as the placeholder it was read
from, never its value: what testing::set_config leaves out of a value
it is given, as config can’t set a secret field.
Auto Trait Implementations§
impl<T = String> !Freeze for Secret<T>
impl<T> Forget for Secret<T>
impl<T> Move for Secret<T>
impl<T> RefUnwindSafe for Secret<T>
impl<T> Send for Secret<T>
impl<T> Sync for Secret<T>
impl<T> Unpin for Secret<T>
impl<T> UnsafeUnpin for Secret<T>
impl<T> UnwindSafe for Secret<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request