Group

Struct Group 

Source
pub struct Group<ID, OP, C, RS, ORD, GS>
where ID: IdentityHandle, OP: OperationId + Ord, RS: Resolver<ID, OP, C, ORD, GS> + Debug, ORD: Orderer<ID, OP, GroupControlMessage<ID, C>>, GS: GroupStore<ID, OP, C, RS, ORD>,
{ /* private fields */ }
Expand description

Decentralised Group Management (DGM).

The Group 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 Group 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 GroupError. For example, attempting to remove a member who is not currently part of the group.

Implementations§

Source§

impl<ID, OP, C, RS, ORD, GS> Group<ID, OP, C, RS, ORD, GS>
where ID: IdentityHandle, OP: OperationId + Ord, RS: Resolver<ID, OP, C, ORD, GS> + Debug, ORD: Orderer<ID, OP, GroupControlMessage<ID, C>>, GS: GroupStore<ID, OP, C, RS, ORD>,

Source

pub fn init(my_id: ID, store: GS, orderer: ORD::State) -> 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.

Trait Implementations§

Source§

impl<ID, OP, C, RS, ORD, GS> Group<ID, OP, C, ORD> for Group<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>> + Clone + Debug, ORD::Operation: Clone, ORD::State: Clone, GS: GroupStore<ID, OP, C, RS, ORD> + Clone + Debug,

Source§

fn create( &self, group_id: ID, members: Vec<(GroupMember<ID>, Access<C>)>, ) -> Result<(Self::State, 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 create_from_remote( &self, remote_operation: ORD::Operation, ) -> Result<Self::State, Self::Error>

Create a group by processing a remote operation.

Source§

fn receive_from_remote( y: Self::State, remote_operation: ORD::Operation, ) -> Result<Self::State, Self::Error>

Update the 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( y: Self::State, adder: ID, added: ID, access: Access<C>, ) -> Result<(Self::State, 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( y: Self::State, remover: ID, removed: ID, ) -> Result<(Self::State, 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( y: Self::State, promoter: ID, promoted: ID, access: Access<C>, ) -> Result<(Self::State, 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( y: Self::State, demoter: ID, demoted: ID, access: Access<C>, ) -> Result<(Self::State, 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 State = GroupCrdtState<ID, OP, C, RS, ORD, GS>

Source§

type Action = GroupControlMessage<ID, C>

Source§

type Error = GroupError<ID, OP, C, RS, ORD, GS>

Auto Trait Implementations§

§

impl<ID, OP, C, RS, ORD, GS> Freeze for Group<ID, OP, C, RS, ORD, GS>
where ID: Freeze, GS: Freeze, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::State: Freeze,

§

impl<ID, OP, C, RS, ORD, GS> RefUnwindSafe for Group<ID, OP, C, RS, ORD, GS>

§

impl<ID, OP, C, RS, ORD, GS> Send for Group<ID, OP, C, RS, ORD, GS>
where ID: Send, GS: Send, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::State: Send, OP: Send, C: Send, RS: Send, ORD: Send,

§

impl<ID, OP, C, RS, ORD, GS> Sync for Group<ID, OP, C, RS, ORD, GS>
where ID: Sync, GS: Sync, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::State: Sync, OP: Sync, C: Sync, RS: Sync, ORD: Sync,

§

impl<ID, OP, C, RS, ORD, GS> Unpin for Group<ID, OP, C, RS, ORD, GS>
where ID: Unpin, GS: Unpin, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::State: Unpin, OP: Unpin, C: Unpin, RS: Unpin, ORD: Unpin,

§

impl<ID, OP, C, RS, ORD, GS> UnwindSafe for Group<ID, OP, C, RS, ORD, GS>
where ID: UnwindSafe, GS: UnwindSafe, <ORD as Orderer<ID, OP, GroupControlMessage<ID, C>>>::State: UnwindSafe, OP: UnwindSafe, C: UnwindSafe, RS: UnwindSafe, ORD: 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