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 (const: unstable) · 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>,
impl Eq for FreshnessContract
Source§impl PartialEq for FreshnessContract
impl PartialEq for FreshnessContract
Source§fn eq(&self, other: &FreshnessContract) -> bool
fn eq(&self, other: &FreshnessContract) -> bool
self and other values to be equal, and is used by ==.