Skip to content

Commit

Permalink
Document :keep_unknown_fields option
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamez committed Nov 3, 2020
1 parent 240c404 commit 241977e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ iex> Msg.unknown_fields(msg)
[{5, 2, <<121, 97, 121, 101>>}]
```

You must always use `unknown_fields/1` as the name of the field (e.g. `__uf__`) is generated at compile-time to avoid collision with the actual fields of the Protobuf message. This function returns a list of tuples `{tag, wire_type, bytes}`. For more information, please see [protobuf encoding guide](https://developers.google.com/protocol-buffers/docs/encoding).
You must always use `unknown_fields/1` as the name of the field (e.g. `__uf__` in the above example) is generated at compile-time to avoid collision with the actual fields of the Protobuf message. This function returns a list of tuples `{tag, wire_type, bytes}`. For more information, please see [protobuf encoding guide](https://developers.google.com/protocol-buffers/docs/encoding).

When you encode a message that contains unknown fields, they will be reencoded in the serialized output.

Expand Down Expand Up @@ -338,6 +338,8 @@ MIX_ENV=prod mix protox.generate --multiple-files --output-path=generated --incl
Doing so, Elixir will be able to parallelize the compilation of generated modules.
Finally, you can pass the option `--keep-unknown-fields=false` to remove support of unknown fields. See [this section](#unknown-fields) for more information.
## Types mapping
The following table shows how Protobuf types are mapped to Elixir's ones.
Expand Down
2 changes: 2 additions & 0 deletions documentation/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Get the default value of a structure field. Note that for Protobuf 3, the defaul

### Unknown fields

_Note_: these functions are not available when the option `:keep_unknown_fields` is set to `false`.

```elixir
@spec clear_unknown_fields(struct) :: struct
clear_unknown_fields(msg)
Expand Down

0 comments on commit 241977e

Please sign in to comment.