     [Enum.reverse(fields), 0, Enum.reverse(values)]
   end
 
-  # Returns the length of the header based on the list of fields.
   defp header_offset(fields) do
     # The last +1 is for the `0` that signals the end of the header.
     fields


    case :small_ints.decode_zigzag_varint(data) do
      {0, rest} ->
        # Remember to return `rest` and not `data` since `rest` doesn't contain
        # the 0 byte that signals the end of the header, while `data` does.
        {Enum.reverse(acc), rest}
      {i, rest} when i < 0 ->
        case decode_property_definition(rest, i, schema) do
          {field, rest} ->
            decode_header(rest, schema, [field|acc])
          :unknown_property_id ->
            :unknown_property_id
        end
      {i, _} when i > 0 ->
        {field, rest} = decode_field_definition(data)

  protocol. This happens because this function is usually called from the parser
  that parsed the byte array.
  """
  @spec decode(binary, Dict.t) :: Document.t
  def decode(data, schema \\ %{}) do
    <<_serialization_version, rest :: binary>> = data

