   end
 
   @doc """
-  Serializes a record using the binary serialization protocol.
-
-  `class_name` is a string containing the class name of the record being
-  encoded. `fields` is a list of `Field` structs.
   """
   def encode(%MarcoPolo.Record{} = record) do
     [0, encode_embedded(record, 1)]

    {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

  Record.defrecordp :typed_field, [:value, :type]

  Record.defrecordp :field_def, [:name, :ptr, :type]

  @doc """
  Parses a binary-serialized record.
