#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SimpleValue {
    False,
    True,
    NullBool,
    NullFloat,
    NullInt,
    NullString,
    NullBytes,
    Code,
    Message,
    Data,
    Success,
    Error,
    Unknown,
    Page,
    Limit,
    Offset,
    Total,
    Id,
    Name,
    Description,
    Type,
    Version,
    Status,
    Url,
    CreateTime,
    UpdateTime,
    DeleteTime,
    Account,
    Token,
    ExpireTime,
    Key,
    Val,
}

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

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