metamessage 0.2.2

MetaMessage (mm) is a structured data exchange protocol. It is self-describing, self-constraining, and self-exemplifying, enabling lossless data exchange. It is designed as a next-generation universal protocol that natively supports AI, humans, and machines.
Documentation
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SimpleValue {
    Null,
    NullBool,
    NullInt,
    NullFloat,
    NullString,
    NullBytes,
    False,
    True,
    Code,
    Message,
    Data,
    Success,
    Error,
    Unknown,
    Page,
    Limit,
    Offset,
    Total,
    Id,
    Name,
    Description,
    Type,
    Version,
    Status,
    Url,
    CreateTime,
    UpdateTime,
    DeleteTime,
    Account,
    Token,
    ExpireTime,
    Key,
}

impl SimpleValue {
    pub fn from_byte(b: u8) -> Option<Self> {
        match b {
            0x00 => Some(SimpleValue::Null),
            0x01 => Some(SimpleValue::NullBool),
            0x02 => Some(SimpleValue::NullInt),
            0x03 => Some(SimpleValue::NullFloat),
            0x04 => Some(SimpleValue::NullString),
            0x05 => Some(SimpleValue::NullBytes),
            0x06 => Some(SimpleValue::False),
            0x07 => Some(SimpleValue::True),
            0x08 => Some(SimpleValue::Code),
            0x09 => Some(SimpleValue::Message),
            0x0A => Some(SimpleValue::Data),
            0x0B => Some(SimpleValue::Success),
            0x0C => Some(SimpleValue::Error),
            0x0D => Some(SimpleValue::Unknown),
            0x0E => Some(SimpleValue::Page),
            0x0F => Some(SimpleValue::Limit),
            0x10 => Some(SimpleValue::Offset),
            0x11 => Some(SimpleValue::Total),
            0x12 => Some(SimpleValue::Id),
            0x13 => Some(SimpleValue::Name),
            0x14 => Some(SimpleValue::Description),
            0x15 => Some(SimpleValue::Type),
            0x16 => Some(SimpleValue::Version),
            0x17 => Some(SimpleValue::Status),
            0x18 => Some(SimpleValue::Url),
            0x19 => Some(SimpleValue::CreateTime),
            0x1A => Some(SimpleValue::UpdateTime),
            0x1B => Some(SimpleValue::DeleteTime),
            0x1C => Some(SimpleValue::Account),
            0x1D => Some(SimpleValue::Token),
            0x1E => Some(SimpleValue::ExpireTime),
            0x1F => Some(SimpleValue::Key),
            _ => None,
        }
    }

    pub fn to_byte(&self) -> u8 {
        match self {
            SimpleValue::Null => 0x00,
            SimpleValue::NullBool => 0x01,
            SimpleValue::NullInt => 0x02,
            SimpleValue::NullFloat => 0x03,
            SimpleValue::NullString => 0x04,
            SimpleValue::NullBytes => 0x05,
            SimpleValue::False => 0x06,
            SimpleValue::True => 0x07,
            SimpleValue::Code => 0x08,
            SimpleValue::Message => 0x09,
            SimpleValue::Data => 0x0A,
            SimpleValue::Success => 0x0B,
            SimpleValue::Error => 0x0C,
            SimpleValue::Unknown => 0x0D,
            SimpleValue::Page => 0x0E,
            SimpleValue::Limit => 0x0F,
            SimpleValue::Offset => 0x10,
            SimpleValue::Total => 0x11,
            SimpleValue::Id => 0x12,
            SimpleValue::Name => 0x13,
            SimpleValue::Description => 0x14,
            SimpleValue::Type => 0x15,
            SimpleValue::Version => 0x16,
            SimpleValue::Status => 0x17,
            SimpleValue::Url => 0x18,
            SimpleValue::CreateTime => 0x19,
            SimpleValue::UpdateTime => 0x1A,
            SimpleValue::DeleteTime => 0x1B,
            SimpleValue::Account => 0x1C,
            SimpleValue::Token => 0x1D,
            SimpleValue::ExpireTime => 0x1E,
            SimpleValue::Key => 0x1F,
        }
    }
}

impl From<SimpleValue> for u8 {
    fn from(v: SimpleValue) -> Self {
        v.to_byte()
    }
}