lzvn 0.1.1

Safe, clean-room LZVN encode/decode support for raw streams and Apple wrappers
Documentation
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum OpcodeKind {
  SmallDistance,
  MediumDistance,
  LargeDistance,
  PreviousDistance,
  SmallLiteral,
  LargeLiteral,
  SmallMatch,
  LargeMatch,
  Nop,
  Eos,
}

pub(crate) fn classify(opcode: u8) -> Option<OpcodeKind> {
  let kind = match opcode {
    0x06 => OpcodeKind::Eos,
    0x0E | 0x16 => OpcodeKind::Nop,
    0xA0..=0xBF => OpcodeKind::MediumDistance,
    0xE0 => OpcodeKind::LargeLiteral,
    0xE1..=0xEF => OpcodeKind::SmallLiteral,
    0xF0 => OpcodeKind::LargeMatch,
    0xF1..=0xFF => OpcodeKind::SmallMatch,
    0x46 | 0x4E | 0x56 | 0x5E | 0x66 | 0x6E | 0x86 | 0x8E | 0x96 | 0x9E | 0xC6 | 0xCE => {
      OpcodeKind::PreviousDistance
    }
    0x07 | 0x0F | 0x17 | 0x1F | 0x27 | 0x2F | 0x37 | 0x3F | 0x47 | 0x4F | 0x57 | 0x5F | 0x67
    | 0x6F | 0x87 | 0x8F | 0x97 | 0x9F | 0xC7 | 0xCF => OpcodeKind::LargeDistance,
    0x1E | 0x26 | 0x2E | 0x36 | 0x3E | 0x70..=0x7F | 0xD0..=0xDF => return None,
    _ => OpcodeKind::SmallDistance,
  };

  Some(kind)
}