pub struct ApprovalRequirement {
pub reason: Option<String>,
pub required_approvers: u32,
pub approver_groups: Vec<String>,
}Expand description
The approval requirement recorded when a gate opened.
A gate opened without approvers carries no requirement at all; the default value (one approval from anyone allowed to answer the gate) applies.
§Examples
use ironflow_store::entities::ApprovalRequirement;
let requirement = ApprovalRequirement {
reason: Some("amount > 10k".to_string()),
required_approvers: 2,
approver_groups: vec!["finance".to_string()],
};
assert!(!requirement.is_satisfied_by(1));
assert!(requirement.is_satisfied_by(2));
assert!(!requirement.allows_everyone());Fields§
§reason: Option<String>Why the handler asked for these approvers, for the audit trail. Never evaluated.
required_approvers: u32Number of distinct approvals needed to resolve the gate.
approver_groups: Vec<String>Groups whose members may vote. Empty means anyone allowed to answer the gate may vote.
Implementations§
Source§impl ApprovalRequirement
impl ApprovalRequirement
Sourcepub fn is_satisfied_by(&self, received: usize) -> bool
pub fn is_satisfied_by(&self, received: usize) -> bool
Whether received distinct approvals are enough to resolve the gate.
§Examples
use ironflow_store::entities::ApprovalRequirement;
let requirement = ApprovalRequirement::default();
assert!(!requirement.is_satisfied_by(0));
assert!(requirement.is_satisfied_by(1));Sourcepub fn allows_everyone(&self) -> bool
pub fn allows_everyone(&self) -> bool
Whether the requirement puts no group restriction on voters.
§Examples
use ironflow_store::entities::ApprovalRequirement;
assert!(ApprovalRequirement::default().allows_everyone());Trait Implementations§
Source§impl Clone for ApprovalRequirement
impl Clone for ApprovalRequirement
Source§fn clone(&self) -> ApprovalRequirement
fn clone(&self) -> ApprovalRequirement
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ApprovalRequirement
impl Debug for ApprovalRequirement
Source§impl Default for ApprovalRequirement
impl Default for ApprovalRequirement
Source§fn default() -> ApprovalRequirement
fn default() -> ApprovalRequirement
One approval, from anyone, no reason.
Source§impl<'de> Deserialize<'de> for ApprovalRequirement
impl<'de> Deserialize<'de> for ApprovalRequirement
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ApprovalRequirement, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ApprovalRequirement, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ApprovalRequirement
impl PartialEq for ApprovalRequirement
Source§impl Serialize for ApprovalRequirement
impl Serialize for ApprovalRequirement
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for ApprovalRequirement
Auto Trait Implementations§
impl Freeze for ApprovalRequirement
impl RefUnwindSafe for ApprovalRequirement
impl Send for ApprovalRequirement
impl Sync for ApprovalRequirement
impl Unpin for ApprovalRequirement
impl UnsafeUnpin for ApprovalRequirement
impl UnwindSafe for ApprovalRequirement
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
Mutably borrows from an owned value. Read more