pub struct AppConfig {
pub snapshot_hmac_key: Option<[u8; 32]>,
pub snapshot_require_signature: bool,
}Expand description
Top-level configuration knobs read from the process environment at server startup.
Today this only carries snapshot-related knobs that don’t have a natural home in any of the middleware-scoped config structs. As the API surface grows, additional cross-cutting knobs land here so the env-var schema stays discoverable.
The snapshot_hmac_key field is a raw [u8; 32] rather than a
tensor_wasm_snapshot::HmacKey (or similar) so this crate does NOT
take a hard dependency on tensor-wasm-snapshot. When the snapshot
route handlers land they can hand the bytes to
SnapshotWriter::with_hmac_sha256_key(key) /
SnapshotReader::with_hmac_sha256_key(key) directly.
Debug is implemented manually so that snapshot_hmac_key renders as
a redacted placeholder. A derived Debug would print all 32 key bytes
any time a caller writes tracing::debug!(?cfg) or similar.
Fields§
§snapshot_hmac_key: Option<[u8; 32]>Optional HMAC-SHA256 signing key for snapshot save/restore.
None means snapshots are written in the v2 (unsigned) format and
restore accepts both signed and unsigned blobs. Some(key) means
snapshots are written in the signed v3 format and restore verifies
any signature present (rejecting tampered blobs).
See Self::snapshot_require_signature for the strict-restore
knob that additionally rejects unsigned v2 blobs.
snapshot_require_signature: boolWhen true, snapshot restore refuses v2 (unsigned) blobs even if
a key is configured. Defaults to false so existing v2 archives
keep working through the migration window.
Implementations§
Source§impl AppConfig
impl AppConfig
Sourcepub fn from_env() -> Result<Self, ConfigError>
pub fn from_env() -> Result<Self, ConfigError>
Load from the process environment.
Reads ENV_SNAPSHOT_HMAC_KEY (hex, 64 chars) and
ENV_SNAPSHOT_REQUIRE_SIGNATURE (true/false,
case-insensitive).
Returns ConfigError when:
TENSOR_WASM_API_SNAPSHOT_HMAC_KEYis set but is not exactly 64 hex characters (each character must be0-9,a-f, orA-F).TENSOR_WASM_API_SNAPSHOT_REQUIRE_SIGNATUREis set to a value that is neithertruenorfalse(case-insensitive).
An unset variable in either case is not an error: the resulting
AppConfig carries None / false for the corresponding fields.
This matches the silent-default behaviour every other
*Config::from_env in this crate exhibits for unset variables —
we deliberately diverge from that pattern only for malformed
values, where a typo in a secret would otherwise be silently
swallowed.
Trait Implementations§
impl Eq for AppConfig
impl StructuralPartialEq for AppConfig
Auto Trait Implementations§
impl Freeze for AppConfig
impl RefUnwindSafe for AppConfig
impl Send for AppConfig
impl Sync for AppConfig
impl Unpin for AppConfig
impl UnsafeUnpin for AppConfig
impl UnwindSafe for AppConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more