Skip to main content

p2panda_auth/
operation.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3use p2panda_core::{Hash, VerifyingKey};
4#[cfg(any(test, feature = "serde"))]
5use serde::{Deserialize, Serialize};
6
7use crate::group::GroupAction;
8use crate::traits::{Conditions, Operation};
9
10/// Concrete groups operation type.
11#[derive(Clone, Debug, PartialEq, Eq)]
12#[cfg_attr(any(test, feature = "serde"), derive(Deserialize, Serialize))]
13pub struct GroupsOperation<C = ()> {
14    pub id: Hash,
15    pub author: VerifyingKey,
16    pub dependencies: Vec<Hash>,
17    pub group_id: VerifyingKey,
18    pub action: GroupAction<VerifyingKey, C>,
19}
20
21/// Implementation of groups Operation trait.
22impl<C> Operation<VerifyingKey, Hash, C> for GroupsOperation<C>
23where
24    C: Conditions,
25{
26    fn id(&self) -> Hash {
27        self.id
28    }
29
30    fn author(&self) -> VerifyingKey {
31        self.author
32    }
33
34    fn dependencies(&self) -> Vec<Hash> {
35        self.dependencies.clone()
36    }
37
38    fn group_id(&self) -> VerifyingKey {
39        self.group_id
40    }
41
42    fn action(&self) -> GroupAction<VerifyingKey, C> {
43        self.action.clone()
44    }
45}