pub enum Expr<T: Element> {
Node(Node<T>),
Or(Or<T>),
And(And<T>),
Choose(Choose<T>),
}Expand description
An expression describing which sets of nodes form a quorum.
Variants§
Node(Node<T>)
A single node
Or(Or<T>)
At least one child expression must be satisfied
And(And<T>)
All child expressions must be satisfied
Choose(Choose<T>)
At least k child expressions must be satisfied
Implementations§
Source§impl<T: Element> Expr<T>
impl<T: Element> Expr<T>
Sourcepub fn quorums(&self) -> Box<dyn Iterator<Item = HashSet<T>> + '_>
pub fn quorums(&self) -> Box<dyn Iterator<Item = HashSet<T>> + '_>
Iterate over the quorums of this expression.
The same quorum can be produced more than once (for example by
a + a), and non-minimal quorums are included (for example
{a, b} from a + a * b).
Sourcepub fn is_quorum(&self, xs: &HashSet<T>) -> bool
pub fn is_quorum(&self, xs: &HashSet<T>) -> bool
Whether xs contains a quorum of this expression.
Sourcepub fn nodes(&self) -> HashSet<Node<T>>
pub fn nodes(&self) -> HashSet<Node<T>>
All nodes in this expression.
If the same identifier appears more than once with different capacities or latency, the first occurrence (in left-to-right order) wins.
Sourcepub fn dual(&self) -> Self
pub fn dual(&self) -> Self
The dual expression: Or and And swap, and choose(k, n) becomes
choose(n - k + 1, n).
Every quorum of an expression intersects every quorum of its dual.
Sourcepub fn resilience(&self) -> usize
pub fn resilience(&self) -> usize
The resilience: the largest number of nodes that can fail while some quorum is still fully alive.
This equals min_hitting_set(quorums) - 1. Duplicate-free
expressions are solved in closed form. Otherwise the hitting set is
solved exactly as an integer program over the minimal quorums.
Trait Implementations§
Source§impl<T: Element> Add for Expr<T>
Expr + Expr produces an Or expression, flattening nested Or
children.
impl<T: Element> Add for Expr<T>
Expr + Expr produces an Or expression, flattening nested Or
children.
Source§impl<T: Element> Mul for Expr<T>
Expr * Expr produces an And expression, flattening nested And
children.
impl<T: Element> Mul for Expr<T>
Expr * Expr produces an And expression, flattening nested And
children.
impl<T: PartialEq + Element> StructuralPartialEq for Expr<T>
Auto Trait Implementations§
impl<T> Freeze for Expr<T>
impl<T> RefUnwindSafe for Expr<T>where
Node<T>: RefUnwindSafe,
Or<T>: RefUnwindSafe,
And<T>: RefUnwindSafe,
Choose<T>: RefUnwindSafe,
impl<T> Send for Expr<T>
impl<T> Sync for Expr<T>
impl<T> Unpin for Expr<T>
impl<T> UnsafeUnpin for Expr<T>
impl<T> UnwindSafe for Expr<T>
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> 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