Skip to main content

Expr

Enum Expr 

Source
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>

Source

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).

Source

pub fn is_quorum(&self, xs: &HashSet<T>) -> bool

Whether xs contains a quorum of this expression.

Source

pub fn elements(&self) -> HashSet<T>

The identifiers of all nodes in this expression.

Source

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.

Source

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.

Source

pub fn dup_free(&self) -> bool

Whether every node identifier appears at most once.

Source

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.

Source§

type Output = Expr<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Clone + Element> Clone for Expr<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Element> Debug for Expr<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Element> Display for Expr<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Element> From<And<T>> for Expr<T>

Source§

fn from(e: And<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Element> From<Choose<T>> for Expr<T>

Source§

fn from(e: Choose<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Element> From<Node<T>> for Expr<T>

Source§

fn from(node: Node<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Element> From<Or<T>> for Expr<T>

Source§

fn from(e: Or<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Element> Mul for Expr<T>

Expr * Expr produces an And expression, flattening nested And children.

Source§

type Output = Expr<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: PartialEq + Element> PartialEq for Expr<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: PartialEq + Element> StructuralPartialEq for Expr<T>

Auto Trait Implementations§

§

impl<T> Freeze for Expr<T>
where Node<T>: Freeze, Or<T>: Freeze, And<T>: Freeze, Choose<T>: Freeze,

§

impl<T> RefUnwindSafe for Expr<T>

§

impl<T> Send for Expr<T>
where Node<T>: Send, Or<T>: Send, And<T>: Send, Choose<T>: Send,

§

impl<T> Sync for Expr<T>
where Node<T>: Sync, Or<T>: Sync, And<T>: Sync, Choose<T>: Sync,

§

impl<T> Unpin for Expr<T>
where Node<T>: Unpin, Or<T>: Unpin, And<T>: Unpin, Choose<T>: Unpin,

§

impl<T> UnsafeUnpin for Expr<T>

§

impl<T> UnwindSafe for Expr<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.