use std::collections::HashSet;
use std::error::Error;
use std::fmt::Debug;
use serde::{Deserialize, Serialize};
#[cfg(any(test, feature = "message_scheme"))]
pub trait AckedGroupMembership<ID, OP> {
type State: Clone + Debug + Serialize + for<'a> Deserialize<'a>;
type Error: Error;
fn create(my_id: ID, initial_members: &[ID]) -> Result<Self::State, Self::Error>;
fn from_welcome(y: Self::State, y_welcome: Self::State) -> Result<Self::State, Self::Error>;
fn add(
y: Self::State,
adder: ID,
added: ID,
operation_id: OP,
) -> Result<Self::State, Self::Error>;
fn remove(
y: Self::State,
remover: ID,
removed: &ID,
operation_id: OP,
) -> Result<Self::State, Self::Error>;
fn ack(y: Self::State, acker: ID, operation_id: OP) -> Result<Self::State, Self::Error>;
fn members_view(y: &Self::State, viewer: &ID) -> Result<HashSet<ID>, Self::Error>;
fn is_add(y: &Self::State, operation_id: OP) -> bool;
fn is_remove(y: &Self::State, operation_id: OP) -> bool;
}
#[cfg(any(test, feature = "data_scheme"))]
pub trait GroupMembership<ID, OP> {
type State: Clone + Debug + Serialize + for<'a> Deserialize<'a>;
type Error: Error;
fn create(my_id: ID, initial_members: &[ID]) -> Result<Self::State, Self::Error>;
fn from_welcome(my_id: ID, y: Self::State) -> Result<Self::State, Self::Error>;
fn add(
y: Self::State,
adder: ID,
added: ID,
operation_id: OP,
) -> Result<Self::State, Self::Error>;
fn remove(
y: Self::State,
remover: ID,
removed: &ID,
operation_id: OP,
) -> Result<Self::State, Self::Error>;
fn members(y: &Self::State) -> Result<HashSet<ID>, Self::Error>;
}