Skip to main content

p2panda_auth/processor/
operation.rs

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