Skip to main content

Joint

Struct Joint 

Source
pub struct Joint<Q> { /* private fields */ }
Expand description

A quorum rule that accepts an ID set only when every one of its rules accepts it.

A membership change can move through a joint of the old and the new rule, whose every quorum is a quorum of both. An empty Joint accepts no set, like an empty Vec<BTreeSet<ID>>.

ids() returns the union of the IDs of every rule, each ID once.

§Examples

use std::collections::BTreeSet;
use std::num::NonZeroU64;

use quorum_set::{Joint, QuorumSet, ThresholdQuorumSet};

let two = NonZeroU64::new(2).unwrap();
let old = ThresholdQuorumSet::new(two, BTreeSet::from([1, 2, 3]));
let new = ThresholdQuorumSet::new(two, BTreeSet::from([2, 3, 4]));
let joint = Joint::new([old, new]);

// {1,2} holds 2 of the old IDs but only 1 of the new IDs.
let accepts_one_two = joint.is_quorum([1, 2].iter());
assert!(!accepts_one_two);
let accepts_one_two_four = joint.is_quorum([1, 2, 4].iter());
assert!(accepts_one_two_four);

Implementations§

Source§

impl<Q> Joint<Q>

Source

pub fn new(rules: impl IntoIterator<Item = Q>) -> Self

Builds a rule that accepts an ID set only when every one of rules accepts it.

Source

pub fn rules(&self) -> &[Q]

Returns the rules, in the order they were given.

Trait Implementations§

Source§

impl<Q: Clone> Clone for Joint<Q>

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<Q: Debug> Debug for Joint<Q>

Source§

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

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

impl<Q> Default for Joint<Q>

Written by hand: derive(Default) would require Q: Default.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Q: Eq> Eq for Joint<Q>

Source§

impl<Q: PartialEq> PartialEq for Joint<Q>

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<Q> QuorumBridge<Joint<Q>> for Joint<Q>
where Q: QuorumSet + Clone, Q::Id: Ord,

Builds the joint of the source and target rules.

Source§

fn joint_with(&self, other: Joint<Q>) -> Self

Return the rules of self followed by the rules of other. Return an empty joint when self or other is empty: an empty joint has no quorum, so a joint with it has no quorum either.

Source§

impl<Q> QuorumIntersection<Joint<Q>> for Joint<Q>
where Q: QuorumIntersection<Q>, Q::Id: Ord,

Two joints are treated as having quorum intersection when some rule of one intersects some rule of the other: every quorum of a joint is also a quorum of each of its rules, so every quorum of one joint then intersects every quorum of the other. This is sufficient but not necessary for that property, so this check answers None for some pairs of joints whose quorums do in fact all intersect.

Source§

fn intersects_with(&self, other: &Joint<Q>) -> Option<bool>

Return the answer of the rule check when each joint holds one rule. For other joints, return Some(true) when some rule of self intersects some rule of other.

When either joint is empty, return Some(true): an empty joint has no quorum, so no pair of quorums can be disjoint.

Return None for every other pair: two rules that do not intersect prove nothing about two joints that contain them.

Source§

impl<Q> QuorumSet for Joint<Q>
where Q: QuorumSet, Q::Id: Ord,

Source§

type Id = <Q as QuorumSet>::Id

Node ID type in this quorum set.
Source§

type Iter = IntoIter<<Q as QuorumSet>::Id>

Iterator over every voter ID tracked by this quorum set. Read more
Source§

fn is_quorum<'a, I>(&self, ids: I) -> bool
where Self::Id: 'a, I: Iterator<Item = &'a Self::Id> + Clone,

Return true if the candidate IDs satisfy this quorum rule. Read more
Source§

fn ids(&self) -> Self::Iter

Return all voter IDs in this quorum set.
Source§

impl<Q: PartialEq> StructuralPartialEq for Joint<Q>

Auto Trait Implementations§

§

impl<Q> Freeze for Joint<Q>
where Vec<Q>: Freeze,

§

impl<Q> RefUnwindSafe for Joint<Q>
where Vec<Q>: RefUnwindSafe,

§

impl<Q> Send for Joint<Q>
where Vec<Q>: Send,

§

impl<Q> Sync for Joint<Q>
where Vec<Q>: Sync,

§

impl<Q> Unpin for Joint<Q>
where Vec<Q>: Unpin,

§

impl<Q> UnsafeUnpin for Joint<Q>
where Vec<Q>: UnsafeUnpin,

§

impl<Q> UnwindSafe for Joint<Q>
where Vec<Q>: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
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, 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.