use super::ClientAuth;
use serde::{Deserialize, Serialize};
use xor_name::XorName;
#[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub enum MsgKind {
AntiEntropy(XorName),
Client {
auth: ClientAuth,
is_spend: bool,
query_index: Option<usize>,
},
Node { name: XorName, is_join: bool },
DataResponse(XorName),
}
impl MsgKind {
pub fn is_ae_msg(&self) -> bool {
matches!(self, MsgKind::AntiEntropy(_))
}
pub fn is_client_spend(&self) -> bool {
match self {
Self::Client { is_spend, .. } => *is_spend,
_ => false,
}
}
pub fn query_index(&self) -> &Option<usize> {
match self {
Self::Client { query_index, .. } => query_index,
_ => &None,
}
}
}