       {:error, @invalid_octet_string}
     end
   end
+
+  @spec tlv(integer, binary) :: pack_result
 
   def tlv(_tag, str) when not is_binary(str), do: {:error, @invalid_tlv_value}
   def tlv(tag, _str) when not is_integer(tag), do: {:error, @invalid_tlv_tag}

    end
  end

  defp valid_kind?(_str, :ascii), do: true

  defp valid_kind?(str, :dec), do: Helpers.dec?(str)

  defp valid_kind?(str, :hex), do: Helpers.hex?(str)

  def octet_string(str, _length) when not is_binary(str), do: {:error, @invalid_octet_string}

  def octet_string(str, length) when is_integer(length) and length >= 0 do
    if byte_size(str) == length do
      {:ok, str}

    end
  end

  @type kind :: :ascii | :hex | :dec
  @type length_spec :: {:fixed, non_neg_integer} | {:max, non_neg_integer}

  @spec c_octet_string(any, length_spec) :: pack_result

  def c_octet_string(nil, length_spec), do: c_octet_string("", length_spec, :ascii)
  def c_octet_string(str, length_spec), do: c_octet_string(str, length_spec, :ascii)

  @spec c_octet_string(any, length_spec, kind) :: pack_result

  def c_octet_string(str, _spec, _kind) when not is_binary(str), do: {:error, @invalid_c_octet_string_value}
  def c_octet_string(nil, length_spec, kind), do: c_octet_string("", length_spec, kind)
