          {"header parse error: #{error}", fname, 0}}
     end
   end
+
+  @spec handle_error(term, binary) :: Error.result
 
   defp handle_error([missing], fname) do
     {:error, :invalid_header,

defmodule Serum.HeaderParser do
  alias Serum.Error

  @type options :: [{atom, value_type}]
  @type value_type :: :string | :integer | {:list, value_type}
  @type value :: binary | integer | [binary] | [integer]

  @spec parse_header(IO.device, binary, options, [atom]) :: Error.result(map)


  defp transform_values([{k, v}|rest], options, acc) do
    atom_k = String.to_existing_atom k
    case transform_value String.trim(v), options[atom_k] do
      {:error, _} = error -> error
      value -> transform_values rest, options, [{atom_k, value}|acc]
    end
