Nestru.Encoder protocol (Nestru v0.2.0) View Source
Link to this section Summary
Functions
Returns the fields map from the encodable struct to be merged to the return map.
Link to this section Types
Specs
t() :: term()
Link to this section Functions
Returns the fields map from the encodable struct to be merged to the return map.
The implementation for Any
makes a map by calling Map.from_struct/1
.
This function is a good place for encoding struct type into the map for further decoding.
The first argument is the encodable struct value adopting the protocol.
If the function returns {:ok, map}
then encoding continues, and the map
is inserted into the encoded map.
If the function returns {:error, message}
tuple, then encoding stops, and
the error is bypassed to the caller.
Any other return value raises an error.