pub struct MembershipChain { /* private fields */ }Expand description
An append-only membership chain.
Entries are sorted by timestamp (HLC string comparison gives causal order).
Implementations§
Source§impl MembershipChain
impl MembershipChain
Sourcepub fn from_entries(
entries: Vec<MembershipEntry>,
) -> Result<Self, MembershipError>
pub fn from_entries( entries: Vec<MembershipEntry>, ) -> Result<Self, MembershipError>
Create a chain from existing entries (e.g., downloaded from storage). Entries are sorted by timestamp and validated on construction.
Sourcepub fn entries(&self) -> &[MembershipEntry]
pub fn entries(&self) -> &[MembershipEntry]
Return the entries in the chain.
Sourcepub fn validate(&self) -> Result<(), MembershipError>
pub fn validate(&self) -> Result<(), MembershipError>
Validate the entire chain.
Rules:
- First entry must be Add with role Owner, self-signed.
- Every entry must have a valid signature.
- Every entry’s author must be a current Owner at that point.
Sourcepub fn is_member_at(&self, pubkey: &str, timestamp: &str) -> bool
pub fn is_member_at(&self, pubkey: &str, timestamp: &str) -> bool
Check if a pubkey was an active member at the given timestamp.
Replays entries up to and including the given timestamp.
Sourcepub fn current_members(&self) -> Vec<(String, MemberRole)>
pub fn current_members(&self) -> Vec<(String, MemberRole)>
Return current active members with their roles.
Sourcepub fn add_entry(
&mut self,
entry: MembershipEntry,
) -> Result<(), MembershipError>
pub fn add_entry( &mut self, entry: MembershipEntry, ) -> Result<(), MembershipError>
Validate and append an entry to the chain.
Trait Implementations§
Source§impl Clone for MembershipChain
impl Clone for MembershipChain
Source§fn clone(&self) -> MembershipChain
fn clone(&self) -> MembershipChain
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MembershipChain
impl Debug for MembershipChain
Source§impl Default for MembershipChain
impl Default for MembershipChain
Source§fn default() -> MembershipChain
fn default() -> MembershipChain
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MembershipChain
impl RefUnwindSafe for MembershipChain
impl Send for MembershipChain
impl Sync for MembershipChain
impl Unpin for MembershipChain
impl UnwindSafe for MembershipChain
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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 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>
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 moreCreates a shared type from an unshared type.