Struct Canonical

Source
pub struct Canonical { /* private fields */ }
Expand description

A collection of Dids and their Oids that is the tip for a given reference for that Did.

The general construction of Canonical is by using the Canonical::reference constructor. For the default branch of a Project, use Canonical::default_branch.

Canonical can then be used for performing calculations about the canonicity of the reference, most importantly the Canonical::quorum.

Implementations§

Source§

impl Canonical

Source

pub fn default_branch<S>( repo: &S, project: &Project, delegates: &NonEmpty<Did>, ) -> Result<Canonical, Error>
where S: ReadRepository,

Construct the set of canonical tips of the Project::default_branch for the given delegates.

Source

pub fn reference<S>( repo: &S, delegates: &NonEmpty<Did>, name: &Qualified<'_>, ) -> Result<Canonical, Error>
where S: ReadRepository,

Construct the set of canonical tips given for the given delegates and the reference name.

Source

pub fn tips(&self) -> impl Iterator<Item = (&Did, &Oid)>

Return the set of Dids and their Oid tip.

Source§

impl Canonical

Source

pub fn modify_vote(&mut self, did: Did, new: Oid)

In some cases, we allow the vote to be modified. For example, when the did is pushing a new commit, we may want to see if the new commit will reach a quorum.

Source

pub fn quorum( &self, threshold: usize, repo: &Repository, ) -> Result<Oid, QuorumError>

Computes the quorum or “canonical” tip based on the tips, of Canonical, and the threshold. This can be described as the latest commit that is included in at least threshold histories. In case there are multiple tips passing the threshold, and they are divergent, an error is returned.

Also returns an error if heads is empty or threshold cannot be satisified with the number of heads given.

Auto Trait Implementations§

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> 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> IntoInit<ZeroInit> for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,