bitwalker / exprotobuf

Protocol Buffers in Elixir made easy!
Apache License 2.0
486 stars 69 forks source link

Serialize not working with inject #90

Closed pallix closed 5 years ago

pallix commented 6 years ago

Serializable.serialize does not work when using inject. I have created a project (https://github.com/pallix/exprotobuf_not_serializing) that illustrates the problem:

iex(2)> alias Protobuf.Serializable                                                                    
Protobuf.Serializable
iex(2)> ExprotobufNotSerializing.Hello.new(id: 1, content: [0]) |> Serializable.serialize()               
** (ErlangError) Erlang error: {:error, {:no_such_key, {:msg, ExprotobufNotSerializing.Hello}, [{{:msg, :Hello}, [{:field, :id, 1, 2, :uint32, :optional, []}, {:field, :content, 2, 3, :bytes, :optional, []}]}]}}
    (gpb) src/gpb.erl:1286: :gpb.keyfetch/2
    (gpb) src/gpb.erl:665: :gpb.encode_msg/2
iex(2)> ExprotobufNotSerializing.HelloOk.Hello.new(id: 1, content: [0]) |> Serializable.serialize()
<<8, 1, 18, 1, 0>>
iex(3)> 

I am using exprotobuf version 1.2.9.