Groups

Struct Groups 

Source
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,

Source

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.

Source

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,

Source§

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>

Query group membership.

Source§

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>

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>

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>

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>

Return true if the given member is currently assigned the Manage access level.

Source§

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,

Source§

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>

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>

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>

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>

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>

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.

Source§

type Error = GroupsError<ID, OP, C, RS, ORD>

Auto Trait Implementations§

§

impl<ID, OP, C, RS, ORD> Freeze for Groups<ID, OP, C, RS, ORD>
where <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::Operation: Sized, ID: Freeze, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::State: Freeze,

§

impl<ID, OP, C, RS, ORD> RefUnwindSafe for Groups<ID, OP, C, RS, ORD>

§

impl<ID, OP, C, RS, ORD> Send for Groups<ID, OP, C, RS, ORD>
where <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::Operation: Sized + Send, ID: Send, RS: Send, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::State: Send, OP: Send, C: Send,

§

impl<ID, OP, C, RS, ORD> Sync for Groups<ID, OP, C, RS, ORD>
where <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::Operation: Sized + Sync, ID: Sync, RS: Sync, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::State: Sync, OP: Sync, C: Sync,

§

impl<ID, OP, C, RS, ORD> Unpin for Groups<ID, OP, C, RS, ORD>
where <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::Operation: Sized + Unpin, ID: Unpin, RS: Unpin, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::State: Unpin, OP: Unpin, C: Unpin,

§

impl<ID, OP, C, RS, ORD> UnwindSafe for Groups<ID, OP, C, RS, ORD>
where <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::Operation: Sized + UnwindSafe, ID: UnwindSafe, RS: UnwindSafe, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::State: UnwindSafe, OP: UnwindSafe, C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V