pub struct GroupCrdtState<ID, OP, C, RS, ORD, GS>where
ID: IdentityHandle,
OP: OperationId,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>>,
GS: GroupStore<ID, OP, C, RS, ORD>,{
pub my_id: ID,
pub group_id: ID,
pub states: HashMap<OP, GroupMembersState<GroupMember<ID>, C>>,
pub operations: HashMap<OP, ORD::Operation>,
pub ignore: HashSet<OP>,
pub graph: DiGraphMap<OP, ()>,
pub orderer_y: ORD::State,
pub group_store: GS,
/* private fields */
}Expand description
State object for GroupCrdt containing the operation graph and all incremental group states.
Requires access to a global orderer and group store.
Fields§
§my_id: IDID of the local actor.
group_id: IDID of the group.
states: HashMap<OP, GroupMembersState<GroupMember<ID>, C>>Group state at every position in the operation graph.
operations: HashMap<OP, ORD::Operation>All operations processed by this group.
ignore: HashSet<OP>All operations who’s actions should be ignored.
graph: DiGraphMap<OP, ()>Operation graph for this group.
orderer_y: ORD::StateState for the orderer.
group_store: GSAll groups known to this instance.
Implementations§
Source§impl<ID, OP, C, RS, ORD, GS> GroupCrdtState<ID, OP, C, RS, ORD, GS>where
ID: IdentityHandle,
OP: OperationId + Ord,
C: Clone + Debug + PartialEq + PartialOrd,
RS: Resolver<ID, OP, C, ORD, GS> + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
GS: GroupStore<ID, OP, C, RS, ORD> + Debug,
impl<ID, OP, C, RS, ORD, GS> GroupCrdtState<ID, OP, C, RS, ORD, GS>where
ID: IdentityHandle,
OP: OperationId + Ord,
C: Clone + Debug + PartialEq + PartialOrd,
RS: Resolver<ID, OP, C, ORD, GS> + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
GS: GroupStore<ID, OP, C, RS, ORD> + Debug,
Sourcepub fn new(
my_id: ID,
group_id: ID,
group_store: GS,
orderer_y: ORD::State,
) -> Self
pub fn new( my_id: ID, group_id: ID, group_store: GS, orderer_y: ORD::State, ) -> Self
Instantiate a new group state.
Sourcepub fn transitive_heads(
&self,
) -> Result<HashSet<OP>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
pub fn transitive_heads( &self, ) -> Result<HashSet<OP>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
Current tips of the group operation graph including all sub-groups.
Sourcepub fn current_state(&self) -> GroupMembersState<GroupMember<ID>, C>
pub fn current_state(&self) -> GroupMembersState<GroupMember<ID>, C>
Current state of this group.
This method gets the state at all graph tips and then merges them together into one new state which represents the current state of the group.
Sourcepub fn state_at(
&self,
dependencies: &HashSet<OP>,
) -> GroupMembersState<GroupMember<ID>, C>
pub fn state_at( &self, dependencies: &HashSet<OP>, ) -> GroupMembersState<GroupMember<ID>, C>
Get the state of a group at a certain point in it’s history.
Sourcepub fn members_at(
&self,
dependencies: &HashSet<OP>,
) -> Vec<(GroupMember<ID>, Access<C>)>
pub fn members_at( &self, dependencies: &HashSet<OP>, ) -> Vec<(GroupMember<ID>, Access<C>)>
Get the group members at a certain point in groups history.
Sourcepub fn transitive_members_at(
&self,
dependencies: &HashSet<OP>,
) -> Result<Vec<(ID, Access<C>)>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
pub fn transitive_members_at( &self, dependencies: &HashSet<OP>, ) -> Result<Vec<(ID, Access<C>)>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
Get all transitive members of the group at a certain point in it’s history.
This method recurses into all sub-groups collecting all “tip” members, which are the stateless “individual” members of a group, likely identified by a public key.
Sourcepub fn members(&self) -> Vec<(GroupMember<ID>, Access<C>)>
pub fn members(&self) -> Vec<(GroupMember<ID>, Access<C>)>
Get all current members of the group.
Sourcepub fn transitive_members(
&self,
) -> Result<Vec<(ID, Access<C>)>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
pub fn transitive_members( &self, ) -> Result<Vec<(ID, Access<C>)>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
Get all current transitive members of the group.
This method recurses into all sub-groups collecting all “tip” members, which are the stateless “individual” members of a group, likely identified by a public key.
Sourcepub fn max_access_identity(
&self,
actor: ID,
dependencies: &HashSet<OP>,
) -> Result<Option<(GroupMember<ID>, Access<C>)>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
pub fn max_access_identity( &self, actor: ID, dependencies: &HashSet<OP>, ) -> Result<Option<(GroupMember<ID>, Access<C>)>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
Get the maximum given access level for an actor at a certain point in the auth graph.
An actor can be a direct individual member of a group, or a transitive member via a sub-group. This is a helper method which finds the hightest access level a member has and returns the group member which gives this actor the found access level.
The passed dependencies array tells us which position in the graph to look at.
Source§impl<ID, OP, C, RS, ORD, GS> GroupCrdtState<ID, OP, C, RS, ORD, GS>where
ID: IdentityHandle + Ord + Display,
OP: OperationId + Ord + Display,
C: Clone + Debug + PartialEq + PartialOrd,
RS: Resolver<ID, OP, C, ORD, GS> + Clone + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Clone + Debug,
ORD::State: Clone,
ORD::Operation: Clone,
GS: GroupStore<ID, OP, C, RS, ORD> + Clone + Debug,
impl<ID, OP, C, RS, ORD, GS> GroupCrdtState<ID, OP, C, RS, ORD, GS>where
ID: IdentityHandle + Ord + Display,
OP: OperationId + Ord + Display,
C: Clone + Debug + PartialEq + PartialOrd,
RS: Resolver<ID, OP, C, ORD, GS> + Clone + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Clone + Debug,
ORD::State: Clone,
ORD::Operation: Clone,
GS: GroupStore<ID, OP, C, RS, ORD> + Clone + Debug,
Trait Implementations§
Source§impl<ID, OP, C: Clone, RS: Clone, ORD, GS> Clone for GroupCrdtState<ID, OP, C, RS, ORD, GS>where
ID: IdentityHandle + Clone,
OP: OperationId + Clone,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Clone,
GS: GroupStore<ID, OP, C, RS, ORD> + Clone,
ORD::Operation: Clone,
ORD::State: Clone,
impl<ID, OP, C: Clone, RS: Clone, ORD, GS> Clone for GroupCrdtState<ID, OP, C, RS, ORD, GS>where
ID: IdentityHandle + Clone,
OP: OperationId + Clone,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Clone,
GS: GroupStore<ID, OP, C, RS, ORD> + Clone,
ORD::Operation: Clone,
ORD::State: Clone,
Source§fn clone(&self) -> GroupCrdtState<ID, OP, C, RS, ORD, GS>
fn clone(&self) -> GroupCrdtState<ID, OP, C, RS, ORD, GS>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<ID, OP, C: Debug, RS: Debug, ORD, GS> Debug for GroupCrdtState<ID, OP, C, RS, ORD, GS>where
ID: IdentityHandle + Debug,
OP: OperationId + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
GS: GroupStore<ID, OP, C, RS, ORD> + Debug,
ORD::Operation: Debug,
ORD::State: Debug,
impl<ID, OP, C: Debug, RS: Debug, ORD, GS> Debug for GroupCrdtState<ID, OP, C, RS, ORD, GS>where
ID: IdentityHandle + Debug,
OP: OperationId + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
GS: GroupStore<ID, OP, C, RS, ORD> + Debug,
ORD::Operation: Debug,
ORD::State: Debug,
Source§impl<ID, OP, C, RS, ORD, GS> GroupMembership<ID, OP, C> for GroupCrdtState<ID, OP, C, RS, ORD, GS>where
ID: IdentityHandle + Display,
OP: OperationId + Ord + Display,
C: Clone + Debug + PartialEq + PartialOrd,
RS: Resolver<ID, OP, C, ORD, GS> + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
GS: GroupStore<ID, OP, C, RS, ORD> + Debug,
impl<ID, OP, C, RS, ORD, GS> GroupMembership<ID, OP, C> for GroupCrdtState<ID, OP, C, RS, ORD, GS>where
ID: IdentityHandle + Display,
OP: OperationId + Ord + Display,
C: Clone + Debug + PartialEq + PartialOrd,
RS: Resolver<ID, OP, C, ORD, GS> + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
GS: GroupStore<ID, OP, C, RS, ORD> + Debug,
Source§fn access(
y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>,
member: &ID,
) -> Result<Access<C>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
fn access( y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>, member: &ID, ) -> Result<Access<C>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
Query the current access level of the given member.
The member is expected to be a “stateless” individual, not a “stateful” group.
Source§fn member_ids(
y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>,
) -> Result<HashSet<ID>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
fn member_ids( y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>, ) -> Result<HashSet<ID>, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
Query group membership.
Source§fn is_member(
y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>,
member: &ID,
) -> Result<bool, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
fn is_member( y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>, member: &ID, ) -> Result<bool, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
Return true if the given ID is an active member of the group.
Source§fn is_puller(
y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>,
member: &ID,
) -> Result<bool, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
fn is_puller( y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>, member: &ID, ) -> Result<bool, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
Return true if the given member is currently assigned the Pull access level.
Source§fn is_reader(
y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>,
member: &ID,
) -> Result<bool, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
fn is_reader( y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>, member: &ID, ) -> Result<bool, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
Return true if the given member is currently assigned the Read access level.
Source§fn is_writer(
y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>,
member: &ID,
) -> Result<bool, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
fn is_writer( y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>, member: &ID, ) -> Result<bool, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
Return true if the given member is currently assigned the Write access level.
Source§fn is_manager(
y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>,
member: &ID,
) -> Result<bool, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
fn is_manager( y: &GroupCrdtState<ID, OP, C, RS, ORD, GS>, member: &ID, ) -> Result<bool, GroupCrdtError<ID, OP, C, RS, ORD, GS>>
Return true if the given member is currently assigned the Manage access level.