pub struct PolicyChain { /* private fields */ }Expand description
An ordered, validated list of NamespacePolicy versions for one namespace.
The chain enforces immutability-by-versioning and only-legal-strengthening
migration (see PolicyChain::push). Each version n owns the half-open
validity range [effective_from_n, effective_from_{n+1});
PolicyChain::active_at resolves the policy in force at a tree position.
Implementations§
Source§impl PolicyChain
impl PolicyChain
Sourcepub fn genesis(policy: NamespacePolicy) -> Result<Self>
pub fn genesis(policy: NamespacePolicy) -> Result<Self>
Start a chain from a genesis policy.
§Errors
Returns Error::PolicyMigrationRejected if the policy is not a valid
genesis (it must have prev_policy_hash == None).
Sourcepub fn versions(&self) -> &[NamespacePolicy]
pub fn versions(&self) -> &[NamespacePolicy]
The ordered policy versions.
Sourcepub fn latest(&self) -> &NamespacePolicy
pub fn latest(&self) -> &NamespacePolicy
The most recent (currently active) policy version.
Sourcepub fn push(&mut self, next: NamespacePolicy) -> Result<()>
pub fn push(&mut self, next: NamespacePolicy) -> Result<()>
Append a migration to the chain, enforcing the #324 rules:
- same
namespace; policy_schema_versionis exactlyprev + 1;effective_fromis strictly greater than the prior version’s;prev_policy_hashequals the prior version’sNamespacePolicy::policy_hash;- the migration does not weaken posture (security level, commitment hash, or VRF mode may only stay the same or strengthen).
§Errors
Returns Error::PolicyMigrationRejected for any rule violation.
Sourcepub fn active_at(&self, position: u64) -> Result<&NamespacePolicy>
pub fn active_at(&self, position: u64) -> Result<&NamespacePolicy>
Resolve the policy version in force at tree position: the version whose
half-open range [effective_from_n, effective_from_{n+1}) contains it.
§Errors
Returns Error::UnknownNamespacePolicy if position precedes the
genesis effective_from (no version was yet in force).
Trait Implementations§
Source§impl Clone for PolicyChain
impl Clone for PolicyChain
Source§fn clone(&self) -> PolicyChain
fn clone(&self) -> PolicyChain
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 PolicyChain
impl Debug for PolicyChain
impl Eq for PolicyChain
Source§impl PartialEq for PolicyChain
impl PartialEq for PolicyChain
Source§fn eq(&self, other: &PolicyChain) -> bool
fn eq(&self, other: &PolicyChain) -> bool
self and other values to be equal, and is used by ==.