use super::*;

pub(crate) trait Entry: Sized {
  type Value;

  fn load(value: Self::Value) -> Self;

  fn store(self) -> Self::Value;
}

pub(super) type BlockHashValue = [u8; 32];

impl Entry for BlockHash {
  type Value = BlockHashValue;

  fn load(value: Self::Value) -> Self {
    BlockHash::from_raw_hash(Hash::from_byte_array(value))
  }

  fn store(self) -> Self::Value {
    *self.as_ref()
  }
}

#[derive(Debug, PartialEq, Copy, Clone)]
pub(crate) struct RuneEntry {
  pub(crate) burned: u128,
  pub(crate) divisibility: u8,
  pub(crate) end: Option<u32>,
  pub(crate) etching: Txid,
  pub(crate) limit: Option<u128>,
  pub(crate) number: u64,
  pub(crate) rune: Rune,
  pub(crate) supply: u128,
  pub(crate) symbol: Option<char>,
  pub(crate) timestamp: u32,
}

pub(super) type RuneEntryValue = (
  u128,         // burned
  u8,           // divisibility
  Option<u32>,  // end
  (u128, u128), // etching
  Option<u128>, // limit
  u64,          // number
  u128,         // rune
  u128,         // supply
  Option<char>, // symbol