pub struct FreshnessContract {
pub domain: String,
pub signature_hash: Option<String>,
pub captured_at_epoch_ms: u64,
pub max_age: Duration,
pub policy_kind: FreshnessPolicyKind,
pub domain_class: DomainClass,
}Expand description
A freshness contract describing the origin and constraints of an identity artifact.
Capture time, target domain, optional signature hash, and the
resolved max-age are all bound at the point of capture so a later
check can detect any of:
- TTL expiration (
now - captured_at > max_age) - Signature rotation (
signaturefield mismatch) - Domain rebinding (
domainfield mismatch)
Fields§
§domain: StringLower-cased host the contract was bound to (e.g. "example.com").
signature_hash: Option<String>Optional opaque signature hash (e.g. "sha256:abc…") the
contract was bound to. None when signatures are not used.
captured_at_epoch_ms: u64Unix epoch milliseconds when the contract was captured.
max_age: DurationResolved max-age for this contract.
policy_kind: FreshnessPolicyKindPolicy band used to resolve max_age.
domain_class: DomainClassDomain class used to resolve max_age.
Implementations§
Source§impl FreshnessContract
impl FreshnessContract
Sourcepub fn with_signature(
domain: &str,
signature: &str,
captured_at_epoch_ms: u64,
max_age: Duration,
policy_kind: FreshnessPolicyKind,
) -> Result<Self, FreshnessError>
pub fn with_signature( domain: &str, signature: &str, captured_at_epoch_ms: u64, max_age: Duration, policy_kind: FreshnessPolicyKind, ) -> Result<Self, FreshnessError>
Build a contract with explicit fields.
§Errors
Returns FreshnessError::InvalidContract when domain is
empty after trimming, when max_age is zero, or when
signature is provided but empty.
Sourcepub fn without_signature(
domain: &str,
captured_at_epoch_ms: u64,
max_age: Duration,
policy_kind: FreshnessPolicyKind,
) -> Result<Self, FreshnessError>
pub fn without_signature( domain: &str, captured_at_epoch_ms: u64, max_age: Duration, policy_kind: FreshnessPolicyKind, ) -> Result<Self, FreshnessError>
Build a contract without a signature.
§Errors
Returns FreshnessError::InvalidContract when domain is
empty after trimming or when max_age is zero.
Sourcepub fn capture_now(
domain: &str,
signature: Option<&str>,
max_age: Duration,
policy_kind: FreshnessPolicyKind,
) -> Result<Self, FreshnessError>
pub fn capture_now( domain: &str, signature: Option<&str>, max_age: Duration, policy_kind: FreshnessPolicyKind, ) -> Result<Self, FreshnessError>
Sourcepub const fn max_age_ms(&self) -> u64
pub const fn max_age_ms(&self) -> u64
Resolved max-age in milliseconds.
Trait Implementations§
Source§impl Clone for FreshnessContract
impl Clone for FreshnessContract
Source§fn clone(&self) -> FreshnessContract
fn clone(&self) -> FreshnessContract
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FreshnessContract
impl Debug for FreshnessContract
Source§impl<'de> Deserialize<'de> for FreshnessContract
impl<'de> Deserialize<'de> for FreshnessContract
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>,
Source§impl PartialEq for FreshnessContract
impl PartialEq for FreshnessContract
Source§impl Serialize for FreshnessContract
impl Serialize for FreshnessContract
impl Eq for FreshnessContract
impl StructuralPartialEq for FreshnessContract
Auto Trait Implementations§
impl Freeze for FreshnessContract
impl RefUnwindSafe for FreshnessContract
impl Send for FreshnessContract
impl Sync for FreshnessContract
impl Unpin for FreshnessContract
impl UnsafeUnpin for FreshnessContract
impl UnwindSafe for FreshnessContract
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.