pub struct Envelope {
pub v: u8,
pub data: Value,
pub memo: Memo,
pub checksum: String,
pub kid: Option<u8>,
}Fields§
§v: u8§data: Value§memo: Memo§checksum: String§kid: Option<u8>Key ID used to sign this envelope. Lets the server hold multiple keys
at once and verify each snapshot under the key it was signed with —
the building block for zero-reload APP_KEY rotation.
Set from APP_KEYS="1:key1,2:key2" env on encode. Verifier looks
up the matching key by kid and falls back to the default
(single-key) path when the field is missing — back-compat with
snapshots issued before this change.
Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn build(app_key: &str, data: Value, memo: Memo) -> Self
pub fn build(app_key: &str, data: Value, memo: Memo) -> Self
Build a fresh envelope from state + memo, signing under the default
key. Use build_with_kid when you need to control which key signs.
Sourcepub fn build_with_kid(kid: u8, app_key: &str, data: Value, memo: Memo) -> Self
pub fn build_with_kid(kid: u8, app_key: &str, data: Value, memo: Memo) -> Self
Build a fresh envelope, signing under the named key and stamping kid
into the envelope so the verifier can pick the same key out of the
rotation set.
Sourcepub fn verify(&self, app_key: &str) -> Result<()>
pub fn verify(&self, app_key: &str) -> Result<()>
Verify against a single key. Convenient when no rotation is in play.
verify_with_keys is the multi-key form for rotation windows.
Sourcepub fn verify_with_keys(&self, keys: &[(u8, &str)]) -> Result<()>
pub fn verify_with_keys(&self, keys: &[(u8, &str)]) -> Result<()>
Verify under a keyring — the rotation-aware path.
Resolution:
- If
self.kidis set, look up that key. If missing, the envelope was signed with a key the server no longer holds → tampered. - If
self.kidisNone, fall back to the default key (the first entry) — back-compat with snapshots from beforekidexisted.
keys is (kid, key) pairs in priority order; the encoder always
uses the first entry to sign new envelopes.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Envelope
impl<'de> Deserialize<'de> for Envelope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Envelope
impl RefUnwindSafe for Envelope
impl Send for Envelope
impl Sync for Envelope
impl Unpin for Envelope
impl UnsafeUnpin for Envelope
impl UnwindSafe for Envelope
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<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