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
impl Canonical
Sourcepub fn default_branch<S>(
repo: &S,
project: &Project,
delegates: &NonEmpty<Did>,
) -> Result<Canonical, Error>where
S: ReadRepository,
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§impl Canonical
impl Canonical
Sourcepub fn modify_vote(&mut self, did: Did, new: Oid)
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.
Sourcepub fn quorum(
&self,
threshold: usize,
repo: &Repository,
) -> Result<Oid, QuorumError>
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§
impl Freeze for Canonical
impl RefUnwindSafe for Canonical
impl Send for Canonical
impl Sync for Canonical
impl Unpin for Canonical
impl UnwindSafe for Canonical
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> 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