pub struct Chain {
pub entries: Vec<Entry>,
/* private fields */
}Expand description
The entries a machine holds for one collection: the chain, and the other entries it has seen that are valid on their own branch (a fork, at the head or further back, and what was signed on top of the branch that lost), so the winner at every position is a function of everything seen and not of the order it arrived in.
Fields§
§entries: Vec<Entry>Implementations§
Source§impl Chain
impl Chain
Sourcepub fn forks(&self) -> &[Entry]
pub fn forks(&self) -> &[Entry]
The entries beside the head that this machine has seen and not outgrown.
Sourcepub fn side(&self) -> impl Iterator<Item = &Entry>
pub fn side(&self) -> impl Iterator<Item = &Entry>
Every entry held that is not in the chain: those beside the head, then the older ones.
Sourcepub fn restore(
collection: &str,
entries: Vec<Entry>,
side: Vec<Entry>,
) -> Result<Chain, MemberError>
pub fn restore( collection: &str, entries: Vec<Entry>, side: Vec<Entry>, ) -> Result<Chain, MemberError>
A chain read back from the store: the entries are checked in order, and each other entry must be valid on its own branch, every entry it follows being held.
Sourcepub fn from_entries(
collection: &str,
entries: Vec<Entry>,
) -> Result<Chain, MemberError>
pub fn from_entries( collection: &str, entries: Vec<Entry>, ) -> Result<Chain, MemberError>
A chain from entries received whole: every one is checked in order.
Sourcepub fn state(&self, collection: &str) -> Result<State, MemberError>
pub fn state(&self, collection: &str) -> Result<State, MemberError>
The members, epoch and policy the chain leaves, or why the chain is not sound (a chain that was altered after it was taken in is an error, not an empty collection).
Sourcepub fn epoch_contested(&self) -> bool
pub fn epoch_contested(&self) -> bool
Whether a removal is in doubt: entries beside the head are held that this machine has not outgrown, and one of them, or the head, removes a member. The key epoch that removal makes is not settled, so nothing is sealed at it.
Sourcepub fn next(
&self,
private: &[u8; 32],
collection: &str,
signer: &str,
change: Change,
) -> Option<Entry>
pub fn next( &self, private: &[u8; 32], collection: &str, signer: &str, change: Change, ) -> Option<Entry>
The next entry, signed by signer (a machine of this chain) with its key’s seed.
Sourcepub fn take(
&mut self,
collection: &str,
entry: Entry,
) -> Result<Taken, MemberError>
pub fn take( &mut self, collection: &str, entry: Entry, ) -> Result<Taken, MemberError>
Takes in an entry from anywhere. It must verify on the entries it follows, which must be held. One that extends the
head extends the chain. One that follows an earlier entry (a fork at the head, or further back where the chain has
gone on) is held beside it, and the chain is settled again over everything held: the same on every machine that
sees it all. When the entry’s branch wins, the entries of the branch it displaces are returned; what was signed on
top of the branch that lost stays off the chain, hash-linked to an entry no longer in it, until its branch wins.
The founding entry is never replaced: a second one is a different collection, and who founded this one is anchored
by the joiner’s own trust (State::anchored).
Trait Implementations§
impl Eq for Chain
impl StructuralPartialEq for Chain
Auto Trait Implementations§
impl Freeze for Chain
impl RefUnwindSafe for Chain
impl Send for Chain
impl Sync for Chain
impl Unpin for Chain
impl UnsafeUnpin for Chain
impl UnwindSafe for Chain
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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