p2panda_auth/traits/
resolver.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3use crate::group::GroupCrdtError;
4use crate::group::{GroupControlMessage, GroupCrdtState};
5use crate::traits::{GroupStore, IdentityHandle, OperationId, Orderer};
6
7/// Interface for implementing a custom group crdt resolver.
8pub trait Resolver<ID, OP, C, ORD, GS>
9where
10    ID: IdentityHandle,
11    OP: OperationId + Ord,
12    ORD: Orderer<ID, OP, GroupControlMessage<ID, C>>,
13    GS: GroupStore<ID, OP, C, Self, ORD>,
14    Self: Sized,
15{
16    /// Check if this message requires that a full state re-build takes place. This would usually
17    /// be due to concurrent operations arriving which require special handling.
18    fn rebuild_required(
19        y: &GroupCrdtState<ID, OP, C, Self, ORD, GS>,
20        msg: &ORD::Operation,
21    ) -> Result<bool, GroupCrdtError<ID, OP, C, Self, ORD, GS>>;
22
23    /// Process all operations and update internal state as required.
24    ///
25    /// This could include updating any internal filter object.
26    #[allow(clippy::type_complexity)]
27    fn process(
28        y: GroupCrdtState<ID, OP, C, Self, ORD, GS>,
29    ) -> Result<GroupCrdtState<ID, OP, C, Self, ORD, GS>, GroupCrdtError<ID, OP, C, Self, ORD, GS>>;
30}