     # {{class_name, fields}, rest}
   end
 
-  # Decodes an header returning a list of field definitions (which is a list of
-  # `%Field{}` structs).
   defp decode_header(data, acc \\ []) do
     {i, rest} = :small_ints.decode_zigzag_varint(data)
 

    {data_ptr, rest}              = decode_data_ptr(rest)
    <<data_type, rest :: binary>> = rest

    # field = %Field{name: field_name, type: int_to_type(data_type), pointer_to_data: data_ptr}

    field = field_def(name: field_name, type: int_to_type(data_type), ptr: data_ptr)
    {field, rest}
  end

  # Decodes fields from the body of a serialized document (`data`) and a list of
  # `%Field{}` structs (with no `:value` field, they're definitions). Returns a
  # list of `%Field{}`s and the rest of the given data.
  defp decode_fields(data, field_definitions) do
    {fields, rest} = Enum.map_reduce field_definitions, data, fn(field_def(name: name) = f, acc) ->
      if field_def(f, :ptr) == 0 do

  end

  @doc """
  """
  def encode(%MarcoPolo.Record{} = record) do
    [0, encode_embedded(record, 1)]
