package gs.std.v0.core

import java.util.HexFormat

/** Implementation of [[Decoder]] for Hexadecimal strings.
  */
object HexDecoder extends Decoder[Hex]:
  private lazy val h: HexFormat = HexFormat.of()

  /** @inheritDocs
    */
  override def decode(input: Hex): Array[Byte] =
    h.parseHex(input.data)

  /** Decode some arbitrary string data.
    *
    * @param input
    *   The data to decode.
    * @return
    *   The decoded bytes.
    */
  def decodeUnsafe(input: String): Array[Byte] =
    h.parseHex(input)
