pub struct Groups<ID, OP, C, RS, ORD>where
ID: IdentityHandle,
OP: OperationId + Ord,
C: Conditions,
RS: Resolver<ID, OP, C, ORD::Operation, State = GroupCrdtInnerState<ID, OP, C, ORD::Operation>> + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
ORD::Operation: Clone,{ /* private fields */ }Expand description
Decentralised Group Management (DGM).
The Groups provides a high-level interface for creating and updating groups. These groups
provide a means for restricting access to application data and resources. Groups are
comprised of members, which may be individuals or groups, and are assigned a user-chosen
identity. Each member is assigned a unique user-chosen identifier and access level. Access
levels are used to enforce restrictions over access to data and the mutation of that data.
They are also used to grant permissions which allow for mutating the group state by adding,
removing and modifying the access level of other members.
Each Groups method performs internal validation to ensure that the desired group action is
valid in light of the current group state. Attempting to perform an invalid action results in a
GroupsError. For example, attempting to remove a member who is not currently part of the
group.
Implementations§
Source§impl<ID, OP, C, RS, ORD> Groups<ID, OP, C, RS, ORD>where
ID: IdentityHandle,
OP: OperationId + Ord,
C: Conditions,
RS: Resolver<ID, OP, C, ORD::Operation, State = GroupCrdtInnerState<ID, OP, C, ORD::Operation>> + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
ORD::Operation: Clone,
impl<ID, OP, C, RS, ORD> Groups<ID, OP, C, RS, ORD>where
ID: IdentityHandle,
OP: OperationId + Ord,
C: Conditions,
RS: Resolver<ID, OP, C, ORD::Operation, State = GroupCrdtInnerState<ID, OP, C, ORD::Operation>> + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
ORD::Operation: Clone,
Sourcepub fn new(my_id: ID, y: GroupCrdtState<ID, OP, C, ORD>) -> Self
pub fn new(my_id: ID, y: GroupCrdtState<ID, OP, C, ORD>) -> Self
Initialise the Group state so that groups can be created and updated.
Requires the identifier of the local actor, as well as a group store and orderer.
Sourcepub fn take_state(self) -> GroupCrdtState<ID, OP, C, ORD>
pub fn take_state(self) -> GroupCrdtState<ID, OP, C, ORD>
Take the current state from the groups struct consuming self in the process.
Trait Implementations§
Source§impl<ID, OP, C, RS, ORD> GroupMembership<ID, OP, C> for Groups<ID, OP, C, RS, ORD>where
ID: IdentityHandle,
OP: OperationId + Ord,
C: Conditions,
RS: Resolver<ID, OP, C, ORD::Operation, State = GroupCrdtInnerState<ID, OP, C, ORD::Operation>> + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
ORD::Operation: Clone,
impl<ID, OP, C, RS, ORD> GroupMembership<ID, OP, C> for Groups<ID, OP, C, RS, ORD>where
ID: IdentityHandle,
OP: OperationId + Ord,
C: Conditions,
RS: Resolver<ID, OP, C, ORD::Operation, State = GroupCrdtInnerState<ID, OP, C, ORD::Operation>> + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
ORD::Operation: Clone,
Source§fn access(&self, group_id: ID, member: ID) -> Result<Access<C>, Self::Error>
fn access(&self, group_id: ID, member: ID) -> Result<Access<C>, Self::Error>
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(&self, group_id: ID) -> Result<HashSet<ID>, Self::Error>
fn member_ids(&self, group_id: ID) -> Result<HashSet<ID>, Self::Error>
Query group membership.
Source§fn is_member(&self, group_id: ID, member: ID) -> Result<bool, Self::Error>
fn is_member(&self, group_id: ID, member: ID) -> Result<bool, Self::Error>
Return true if the given ID is an active member of the group.
Source§fn is_puller(&self, group_id: ID, member: ID) -> Result<bool, Self::Error>
fn is_puller(&self, group_id: ID, member: ID) -> Result<bool, Self::Error>
Return true if the given member is currently assigned the Pull access level.
Source§fn is_reader(&self, group_id: ID, member: ID) -> Result<bool, Self::Error>
fn is_reader(&self, group_id: ID, member: ID) -> Result<bool, Self::Error>
Return true if the given member is currently assigned the Read access level.
Source§fn is_writer(&self, group_id: ID, member: ID) -> Result<bool, Self::Error>
fn is_writer(&self, group_id: ID, member: ID) -> Result<bool, Self::Error>
Return true if the given member is currently assigned the Write access level.
Source§fn is_manager(&self, group_id: ID, member: ID) -> Result<bool, Self::Error>
fn is_manager(&self, group_id: ID, member: ID) -> Result<bool, Self::Error>
Return true if the given member is currently assigned the Manage access level.
type Error = GroupsError<ID, OP, C, RS, ORD>
Source§impl<ID, OP, C, RS, ORD> Groups<ID, OP, C, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::Operation> for Groups<ID, OP, C, RS, ORD>where
ID: IdentityHandle,
OP: OperationId + Ord,
C: Conditions,
RS: Resolver<ID, OP, C, ORD::Operation, State = GroupCrdtInnerState<ID, OP, C, ORD::Operation>> + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
ORD::Operation: Clone,
impl<ID, OP, C, RS, ORD> Groups<ID, OP, C, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::Operation> for Groups<ID, OP, C, RS, ORD>where
ID: IdentityHandle,
OP: OperationId + Ord,
C: Conditions,
RS: Resolver<ID, OP, C, ORD::Operation, State = GroupCrdtInnerState<ID, OP, C, ORD::Operation>> + Debug,
ORD: Orderer<ID, OP, GroupControlMessage<ID, C>> + Debug,
ORD::Operation: Clone,
Source§fn create(
&mut self,
group_id: ID,
members: Vec<(GroupMember<ID>, Access<C>)>,
) -> Result<ORD::Operation, Self::Error>
fn create( &mut self, group_id: ID, members: Vec<(GroupMember<ID>, Access<C>)>, ) -> Result<ORD::Operation, Self::Error>
Create a group.
The creator of the group is automatically added as a manager.
The caller of this method must ensure that the given group_id is globally unique. For
example, using a collision-resistant hash.
Source§fn receive_from_remote(
&mut self,
remote_operation: ORD::Operation,
) -> Result<(), Self::Error>
fn receive_from_remote( &mut self, remote_operation: ORD::Operation, ) -> Result<(), Self::Error>
Update a group by processing a remotely-authored action.
The group_id of the given operation must be the same as that of the given y; failure to
meet this condition will result in an error.
Source§fn add(
&mut self,
group_id: ID,
adder: ID,
added: ID,
access: Access<C>,
) -> Result<ORD::Operation, Self::Error>
fn add( &mut self, group_id: ID, adder: ID, added: ID, access: Access<C>, ) -> Result<ORD::Operation, Self::Error>
Add a group member.
The adder must be a manager and the added identity must not already be a member of
the group; failure to meet these conditions will result in an error.
Source§fn remove(
&mut self,
group_id: ID,
remover: ID,
removed: ID,
) -> Result<ORD::Operation, Self::Error>
fn remove( &mut self, group_id: ID, remover: ID, removed: ID, ) -> Result<ORD::Operation, Self::Error>
Remove a group member.
The remover must be a manager and the removed identity must already be a member
of the group; failure to meet these conditions will result in an error. A member can only
remove themself from the group if they are a manager.
Source§fn promote(
&mut self,
group_id: ID,
promoter: ID,
promoted: ID,
access: Access<C>,
) -> Result<ORD::Operation, Self::Error>
fn promote( &mut self, group_id: ID, promoter: ID, promoted: ID, access: Access<C>, ) -> Result<ORD::Operation, Self::Error>
Promote a group member to the given access level.
The promoter must be a manager and the promoted identity must already be a member of
the group; failure to meet these conditions will result in an error. A redundant access
level assignment will also result in an error; for example, if the promoted member
currently has Read access and the given access is also Read.
Source§fn demote(
&mut self,
group_id: ID,
demoter: ID,
demoted: ID,
access: Access<C>,
) -> Result<ORD::Operation, Self::Error>
fn demote( &mut self, group_id: ID, demoter: ID, demoted: ID, access: Access<C>, ) -> Result<ORD::Operation, Self::Error>
Demote a group member to the given access level.
The demoter must be a manager and the demoted identity must already be a member of
the group; failure to meet these conditions will result in an error. A redundant access
level assignment will also result in an error; for example, if the demoted member
currently has Manage access and the given access is also Manage.