use crate::encryption::json_indexer::prefix_mac::UpdatePrefixMac;
#[cfg_attr(test, derive(Debug, PartialEq, Eq))]
pub(crate) enum MacTerm {
Bool(bool),
Null,
Map,
Array,
}
impl MacTerm {
pub(crate) const INFO_TRUE: &'static str = "TRUE00";
pub(crate) const INFO_FALSE: &'static str = "FALSE0";
pub(crate) const INFO_NULL: &'static str = "NULL00";
pub(crate) const INFO_MAP: &'static str = "MAP0{}";
pub(crate) const INFO_ARRY: &'static str = "ARRY[]";
pub(crate) fn as_str(&self) -> &'static str {
match self {
MacTerm::Bool(true) => Self::INFO_TRUE,
MacTerm::Bool(false) => Self::INFO_FALSE,
MacTerm::Null => Self::INFO_NULL,
MacTerm::Map => Self::INFO_MAP,
MacTerm::Array => Self::INFO_ARRY,
}
}
}
impl<M> UpdatePrefixMac<MacTerm> for M
where
for<'u> M: UpdatePrefixMac<&'u str>,
{
fn update(&mut self, value: MacTerm) {
self.update(value.as_str());
}
}